Prometheus Emitter
Prometheus Emitter
prometheus-emitter 확장은 Druid 메트릭을 Prometheus 서버가 수집할 수 있도록 노출해요. exporter 또는 pushgateway 전략을 선택해 사용할 수 있어요.
출처: 문서
본문
이 Apache Druid 확장을 사용하려면 extensions load list에 prometheus-emitter를 포함해 주세요.
prometheus-emitter
Introduction
이 확장은 Prometheus 서버(https://prometheus.io/)가 수집할 수 있도록 Druid 메트릭을 노출해요.
Emitter는 druid.emitter=prometheus 설정을 하거나 composing emitter 목록에 prometheus를 포함해 활성화해요.
Configuration
Prometheus emitter의 모든 구성 파라미터는 druid.emitter.prometheus 아래에 있어요.
| 속성 | 설명 | 필수 | 기본값 |
|---|---|---|---|
druid.emitter.prometheus.strategy |
prometheus 메트릭을 노출하는 전략. exporter와 pushgateway 중 하나여야 해요. 기본 전략 exporter는 스크래핑 목적으로 메트릭을 노출해요. Peon 태스크(수명이 짧은 작업)는 pushgateway 전략을 사용해야 해요. |
yes | exporter |
druid.emitter.prometheus.port |
prometheus HTTPServer를 노출할 포트. exporter 전략을 사용할 때 필요해요. |
no | none |
druid.emitter.prometheus.namespace |
선택적 메트릭 namespace. 정규식 [a-zA-Z_:][a-zA-Z0-9_:]*과 일치해야 해요. |
no | druid |
druid.emitter.prometheus.dimensionMapPath |
모든 Druid 메트릭에 대해 Prometheus 메트릭 타입, 원하는 dimension, conversionFactor, histogram buckets, help text를 정의하는 JSON 파일. | no | 기본 매핑 제공. 아래 참고. |
druid.emitter.prometheus.addHostAsLabel |
hostname을 prometheus label로 포함할지 여부 플래그. | no | false |
druid.emitter.prometheus.addServiceAsLabel |
druid 서비스 이름(예: druid/broker, druid/coordinator 등)을 prometheus label로 포함할지 여부 플래그. |
no | false |
druid.emitter.prometheus.pushGatewayAddress |
Pushgateway 주소. pushgateway 전략을 사용할 때 필요해요. |
no | none |
druid.emitter.prometheus.flushPeriod |
pushgateway 전략 사용 시 메트릭이 매 flushPeriod 초마다 내보내져요. exporter 전략 사용 시 이는 메트릭 TTL을 구성해서, 메트릭 값이 flushPeriod 초 안에 갱신되지 않으면 더 이상 내보내지지 않게 돼요. TTL은 메트릭별 각 고유 label 조합에 적용된다는 점에 유의하세요. 최소 3 * scrape_interval로 설정하는 것을 권장해요. |
pushgateway 전략 사용 시 필수, 그 외 선택 |
pushgateway 전략: 15초. exporter 전략: 없음. |
druid.emitter.prometheus.extraLabels |
모든 메트릭에 대한 추가 label의 JSON key-value 쌍. 키(label 이름)는 정규식 [a-zA-Z_:][a-zA-Z0-9_:]*과 일치해야 해요. 예: {"cluster_name": "druid_cluster1", "env": "staging"}. |
no | none |
druid.emitter.prometheus.deletePushGatewayMetricsOnShutdown |
태스크 종료 시 Pushgateway에서 메트릭을 삭제할지 여부 플래그. pushgateway 전략을 사용할 때만 동작해요. 이 기능을 사용하면 배치로 실행되는 태스크의 오래된 메트릭을 삭제할 수 있어요. 그렇지 않으면 Pushgateway는 TTL 메커니즘이 없으므로 이 오래된 메트릭을 무기한 저장해서, 이미 Prometheus가 스크랩한 데이터를 메모리로 붙잡고 있게 돼요. |
no | false |
druid.emitter.prometheus.waitForShutdownDelay |
peon 태스크가 종료 시 Pushgateway에서 메트릭을 삭제하기를 기다리는 시간(밀리초, 예: 60_000). pushgateway 전략을 사용하고 deletePushGatewayMetricsOnShutdown이 true일 때만 적용돼요. 구성된 지연이 Peon의 druid.indexer.task.gracefulShutdownTimeout 값보다 크다면 peon 태스크가 gateway에서 메트릭을 삭제한다는 보장이 없어요. 최상의 결과를 위해, Druid가 정리 전에 메트릭을 스크랩하도록 이 값을 구성된 Prometheus scrape_interval의 1.2배로 설정하세요. |
no | none |
Ports for colocated Druid processes
어떤 경우에는 Druid 프로세스들이 같은 호스트에 위치할 수 있어요. 예를 들어 Broker와 Router가 같은 서버를 공유할 수 있어요. 다른 콜로케이션 프로세스로는 Historical과 Middle Manager, 또는 Coordinator와 Overlord가 있어요. 콜로케이션 프로세스가 있을 때는 각 호스트의 각 프로세스에 druid.emitter.prometheus.port를 별도로 지정해 주세요. 예를 들어 Broker와 Router가 같은 호스트를 공유하더라도, Broker runtime properties와 Router runtime properties 각각에 druid.emitter.prometheus.port를 나열해야 하고, 두 포트 값은 달라야 해요.
Override properties for Peon Tasks
Peon 태스크는 middle manager가 동적으로 만들고 동적인 host와 port 주소를 가져요. exporter 전략은 Prometheus가 고정 주소에서만 읽을 수 있게 하므로 peon 태스크에는 사용할 수 없어요. 그래서 이 태스크들은 druid 메트릭을 prometheus gateway로 밀어 넣기 위해 pushgateway 전략을 사용하도록 구성해야 해요.
이 emitter가 전역적으로 exporter 전략을 사용하도록 구성된 경우, 생성된 peon 태스크가 여전히 pushgateway 전략을 사용할 수 있도록 위 구성 중 일부를 middle manager에서 덮어써야 해요.
#
# Override global prometheus emitter configuration for peon tasks to use `pushgateway` strategy.
# Other configurations can also be overridden by adding `druid.indexer.fork.property.` prefix to above configuration properties.
#
druid.indexer.fork.property.druid.emitter.prometheus.strategy=pushgateway
druid.indexer.fork.property.druid.emitter.prometheus.pushGatewayAddress=http://<push-gateway-address>
Metric names
모든 메트릭 이름과 label은 Prometheus 표준에 맞게 재포맷돼요.
- 이름의 경우: 영숫자, 밑줄, 콜론이 아닌 모든 문자(
[^a-zA-Z_:][^a-zA-Z0-9_:]*일치)가_로 바뀌어요. - label의 경우: 영숫자나 밑줄이 아닌 모든 문자(
[^a-zA-Z0-9_][^a-zA-Z0-9_]*일치)가_로 바뀌어요.
Metric mapping
Prometheus가 수집할 각 메트릭은 타입([timer, counter, guage] 중 하나)을 지정해야 해요. Prometheus Emitter는 이 매핑이 JSON 파일로 제공되기를 기대해요. 추가로 이 매핑은 각 메트릭에 포함할 dimension을 지정해요. Prometheus는 histogram timer가 기본 단위로 Seconds를 사용하기를 기대해요. 초를 기본 단위로 사용하지 않는 timer는 conversionFactor로 기본 시간 단위를 설정할 수 있어요. Histogram timer는 histogramBuckets 파라미터로 커스텀 버킷 구성도 지원해요. 커스텀 버킷이 제공되지 않으면 다음 기본 버킷이 사용돼요: [0.1, 0.25, 0.5, 0.75, 1.0, 2.5, 5.0, 7.5, 10.0, 30.0, 60.0, 120.0, 300.0]. 사용자가 자신의 JSON 파일을 지정하지 않으면 기본 매핑이 사용돼요. 모든 메트릭이 매핑되어야 해요. 매핑되지 않은 메트릭은 추적되지 않아요.
Prometheus 메트릭 경로는 다음 스키마로 구성돼요.
<druid metric name> : {
"dimensions" : <dimension list>,
"type" : <timer|counter|gauge>,
"conversionFactor": <conversionFactor>,
"histogramBuckets": <array of bucket values for timer metric>,
"help" : <help text>
}
예를 들어:
"query/time" : {
"dimensions" : ["dataSource", "type"],
"type" : "timer",
"conversionFactor": 1000.0,
"histogramBuckets": [0.1, 0.25, 0.5, 0.75, 1.0, 2.5, 5.0, 7.5, 10.0, 30.0, 60.0, 120.0, 300.0],
"help": "Seconds taken to complete a query."
}
서로 다른 dimension을 가진 여러 서비스에서 내보내진 메트릭의 경우 메트릭 이름에 서비스 이름이 접두사로 붙어요. 예를 들어:
"druid/coordinator-segment/count" : { "dimensions" : ["dataSource"], "type" : "gauge" },
"druid/historical-segment/count" : { "dimensions" : ["dataSource", "tier", "priority"], "type" : "gauge" }
대부분의 사용 사례에서는 기본 매핑으로 충분해요.
더 알아보기 (Learn more)
- 다른 메트릭 emitter로 StatsD Emitter, Graphite Emitter, InfluxDB Emitter도 살펴보세요.
- Druid Metrics 문서에서 Druid가 내보내는 메트릭 목록을 확인해 보세요.