---
lowercaseOutputName: true
lowercaseOutputLabelNames: true
whitelistObjectNames:
  # Engine Application Versioning Info
  - kafka.connect:type=app-info,client-id=*
  # Connect Worker Rebalancing info
  - kafka.connect:type=connect-worker-rebalance-metrics
  # Connect Co-ordinator Info
  - kafka.connect:type=connect-coordinator-metrics,*
  - kafka.connect:type=connect-metrics,*
  # Worker level metrics for the aggregate as well as per connector level
  - kafka.connect:type=connect-worker-metrics
  - kafka.connect:type=connect-worker-metrics,*
  # Engine Connector Versioning Info
  - kafka.connect:type=connector-metrics,*
  # Task level metrics for every connector running in the current node.
  - kafka.connect:type=*-task-metrics,*
  - kafka.connect:type=task-error-metrics,*
  #  Confluent Replicator JMX Stats
  - confluent.replicator:type=confluent-replicator-task-metrics,*
  # The two lines below are used to pull the Kafka Client Producer & consumer metrics from Connect Workers.
  # If you care about Producer/Consumer metrics for Connect, please uncomment 2 lines below.
  # Please note that this increases the scrape duration by about 1-2 seconds as it needs to parse a lot of data.
  - 'kafka.consumer:*'
  - 'kafka.producer:*'
blacklistObjectNames:
  # This will ignore the admin client metrics from KSQL server and will blacklist certain metrics
  # that do not make sense for ingestion.
  - 'kafka.admin.client:*'
  - 'kafka.consumer:type=*,id=*'
  - 'kafka.producer:type=*,id=*'
  - 'kafka.producer:client-id=confluent.monitoring*,*'
  - 'kafka.*:type=kafka-metrics-count,*'
rules:
  # "kafka.schema.registry:type=app-info,id=*"
  - pattern: 'kafka.connect<type=app-info, client-id=(.+)><>(.+): (.+)'
    name: 'kafka_connect_app_info'
    value: 1
    labels:
      client-id: '$1'
      $2: '$3'
    type: UNTYPED
  # kafka.connect:type=connect-worker-rebalance-metrics
  - pattern: 'kafka.connect<type=connect-worker-rebalance-metrics><>([^:]+)'
    name: 'kafka_connect_connect_worker_rebalance_metrics_$1'
  # kafka.connect:type=connect-coordinator-metrics,client-id=*
  # kafka.connect:type=connect-metrics,client-id=*
  - pattern: 'kafka.connect<type=(.+), client-id=(.+)><>([^:]+)'
    name: kafka_connect_$1_$3
    labels:
      client_id: $2
  # kafka.connect:type=connect-worker-metrics
  - pattern: 'kafka.connect<type=connect-worker-metrics><>([^:]+)'
    name: kafka_connect_connect_worker_metrics_$1
    labels:
      connector: 'aggregate'
  # kafka.connect:type=connect-worker-metrics,connector=*
  - pattern: 'kafka.connect<type=connect-worker-metrics, connector=(.+)><>([^:]+)'
    name: kafka_connect_connect_worker_metrics_$2
    labels:
      connector: $1
  # kafka.connect:type=connector-metrics,connector=*
  - pattern: 'kafka.connect<type=connector-metrics, connector=(.+)><>(.+): (.+)'
    value: 1
    name: kafka_connect_connector_metrics
    labels:
      connector: $1
      $2: $3
    type: UNTYPED
  # kafka.connect:type=*-task-metrics,*
  # kafka.connect:type=source-task-metrics,connector=*,task=*
  # kafka.connect:type=sink-task-metrics,connector=*,task=*
  # kafka.connect:type=connector-task-metrics,connector=*,task=*
  - pattern: "kafka.connect<type=(.+)-task-metrics, connector=(.+), task=(\\d+)><>(.+): (.+)"
    name: kafka_connect_$1_task_metrics_$4
    labels:
      connector: '$2'
      task: '$3'
  # kafka.connect:type=task-error-metrics,*
  # kafka.connect:type=task-error-metrics,connector=*,task=*
  - pattern: "kafka.connect<type=task-error-metrics, connector=(.+), task=(\\d+)><>([^:]+)"
    name: kafka_connect_task_error_metrics_$3
    labels:
      connector: '$1'
      task: '$2'
  # confluent.replicator:type=confluent-replicator-task-metrics,* : confluent-replicator-task-topic-partition-*: Number Values
  - pattern: 'confluent.replicator<type=confluent-replicator-task-metrics, confluent-replicator-(.*)=(.+), confluent-replicator-(.+)=(.+), confluent-replicator-(.+)=(.+), confluent-replicator-(.+)=(.+)><>confluent-replicator-task-topic-partition-(.*): (.*)'
    name: confluent_replicator_task_metrics_$9
    labels:
      $1: '$2'
      $3: '$4'
      $5: '$6'
      $7: '$8'
  # confluent.replicator:type=confluent-replicator-task-metrics,* : Strings
  - pattern: 'confluent.replicator<type=confluent-replicator-task-metrics, confluent-replicator-(.*)=(.+), confluent-replicator-(.+)=(.+), confluent-replicator-(.+)=(.+), confluent-replicator-(.+)=(.+)><>(confluent-replicator-destination-cluster|confluent-replicator-source-cluster|confluent-replicator-destination-topic-name): (.*)'
    name: confluent_replicator_task_metrics_info
    value: 1
    labels:
      $1: '$2'
      $3: '$4'
      $5: '$6'
      $7: '$8'
      $9: '$10'
  # "kafka.consumer:type=app-info,client-id=*"
  # "kafka.producer:type=app-info,client-id=*"
  - pattern: 'kafka.(.+)<type=app-info, client-id=(.+)><>(.+): (.+)'
    value: 1
    name: kafka_$1_app_info
    labels:
      client_type: $1
      client_id: $2
      $3: $4
    type: UNTYPED
  # "kafka.consumer:type=consumer-metrics,client-id=*, protocol=*, cipher=*"
  # "kafka.consumer:type=type=consumer-fetch-manager-metrics,client-id=*, topic=*, partition=*"
  # "kafka.producer:type=producer-metrics,client-id=*, protocol=*, cipher=*"
  - pattern: 'kafka.(.+)<type=(.+), (.+)=(.+), (.+)=(.+), (.+)=(.+)><>(.+):'
    name: kafka_$1_$2_$9
    type: GAUGE
    labels:
      client_type: $1
      $3: '$4'
      $5: '$6'
      $7: '$8'
  # "kafka.consumer:type=consumer-node-metrics,client-id=*, node-id=*"
  # "kafka.consumer:type=consumer-fetch-manager-metrics,client-id=*, topic=*"
  # "kafka.producer:type=producer-node-metrics,client-id=*, node-id=*"
  # "kafka.producer:type=producer-topic-metrics,client-id=*, topic=*"
  - pattern: 'kafka.(.+)<type=(.+), (.+)=(.+), (.+)=(.+)><>(.+):'
    name: kafka_$1_$2_$7
    type: GAUGE
    labels:
      client_type: $1
      $3: '$4'
      $5: '$6'
  # "kafka.consumer:type=consumer-fetch-manager-metrics,client-id=*"
  # "kafka.consumer:type=consumer-metrics,client-id=*"
  # "kafka.producer:type=producer-metrics,client-id=*"
  - pattern: 'kafka.(.+)<type=(.+), (.+)=(.+)><>(.+):'
    name: kafka_$1_$2_$5
    type: GAUGE
    labels:
      client_type: $1
      $3: '$4'
  - pattern: 'kafka.(.+)<type=(.+)><>(.+):'
    name: kafka_$1_$2_$3
    labels:
      client_type: $1
