Prometheus Emitter

To use this Apache Druid extension, include prometheus-emitter in the extensions load list.

Introduction

This extension exposes Druid metrics for collection by a Prometheus server (https://prometheus.io/).

Emitter is enabled by setting druid.emitter=prometheus configs or include prometheus in the composing emitter list.

Configuration

All the configuration parameters for the Prometheus emitter are under druid.emitter.prometheus.

propertydescriptionrequired?default
druid.emitter.prometheus.strategyThe strategy to expose prometheus metrics.
Should be one of exporter and pushgateway. Default strategy exporter would expose metrics for scraping purpose. Peon tasks (short-lived jobs) should use pushgateway strategy.
yesexporter
druid.emitter.prometheus.portThe port on which to expose the prometheus HTTPServer. Required if using exporter strategy.nonone
druid.emitter.prometheus.namespaceOptional metric namespace. Must match the regex [a-zA-Z:][a-zA-Z0-9:]*nodruid
druid.emitter.prometheus.dimensionMapPathJSON file defining the Prometheus metric type, desired dimensions, help text, and conversionFactor for every Druid metric.noDefault mapping provided. See below.
druid.emitter.prometheus.addHostAsLabelFlag to include the hostname as a prometheus label.nofalse
druid.emitter.prometheus.addServiceAsLabelFlag to include the druid service name (e.g. druid/broker, druid/coordinator, etc.) as a prometheus label.nofalse
druid.emitter.prometheus.pushGatewayAddressPushgateway address. Required if using pushgateway strategy.nonone
druid.emitter.prometheus.flushPeriodEmit metrics to Pushgateway every flushPeriod seconds. Required if pushgateway strategy is used.no15

Ports for colocated Druid processes

In certain instances, Druid processes may be colocated on the same host. For example, the Broker and Router may share the same server. Other colocated processes include the Historical and MiddleManager or the Coordinator and Overlord. When you have colocated processes, specify druid.emitter.prometheus.port separately for each process on each host. For example, even if the Broker and Router share the same host, the Broker runtime properties and the Router runtime properties each need to list druid.emitter.prometheus.port, and the port value for both must be different.

Override properties for Peon Tasks

Peon tasks are created dynamically by middle managers and have dynamic host and port addresses. Since the exporter strategy allows Prometheus to read only from a fixed address, it cannot be used for peon tasks. So, these tasks need to be configured to use pushgateway strategy to push metrics from Druid to prometheus gateway.

If this emitter is configured to use exporter strategy globally, some of the above configurations need to be overridden in the middle manager so that spawned peon tasks can still use the pushgateway strategy.

  1. #
  2. # Override global prometheus emitter configuration for peon tasks to use `pushgateway` strategy.
  3. # Other configurations can also be overridden by adding `druid.indexer.fork.property.` prefix to above configuration properties.
  4. #
  5. druid.indexer.fork.property.druid.emitter.prometheus.strategy=pushgateway
  6. druid.indexer.fork.property.druid.emitter.prometheus.pushGatewayAddress=http://<push-gateway-address>

Metric names

All metric names and labels are reformatted to match Prometheus standards.

  • For names: all characters which are not alphanumeric, underscores, or colons (matching [^a-zA-Z_:][^a-zA-Z0-9_:]*) are replaced with _
  • For labels: all characters which are not alphanumeric or underscores (matching [^a-zA-Z0-9_][^a-zA-Z0-9_]*) are replaced with _

Metric mapping

Each metric to be collected by Prometheus must specify a type, one of [timer, counter, guage]. Prometheus Emitter expects this mapping to be provided as a JSON file. Additionally, this mapping specifies which dimensions should be included for each metric. Prometheus expects histogram timers to use Seconds as the base unit. Timers which do not use seconds as a base unit can use the conversionFactor to set the base time unit. If the user does not specify their own JSON file, a default mapping is used. All metrics are expected to be mapped. Metrics which are not mapped will not be tracked.

Prometheus metric path is organized using the following schema:

  1. <druid metric name> : {
  2. "dimensions" : <dimension list>,
  3. "type" : <timer|counter|gauge>,
  4. "conversionFactor": <conversionFactor>,
  5. "help" : <help text>
  6. }

For example:

  1. "query/time" : {
  2. "dimensions" : ["dataSource", "type"],
  3. "type" : "timer",
  4. "conversionFactor": 1000.0,
  5. "help": "Seconds taken to complete a query."
  6. }

For metrics which are emitted from multiple services with different dimensions, the metric name is prefixed with the service name. For example:

  1. "coordinator-segment/count" : { "dimensions" : ["dataSource"], "type" : "gauge" },
  2. "historical-segment/count" : { "dimensions" : ["dataSource", "tier", "priority"], "type" : "gauge" }

For most use cases, the default mapping is sufficient.