---
# Kafka Producer metrics
rules:
  - bean: kafka.producer:client-id=*,type=producer-metrics
    metricAttribute:
      client-id: param(client-id)
    prefix: kafka.producer.
    type: gauge
    mapping:
      io-wait-time-ns-avg:
        desc: The average length of time the I/O thread spent waiting for a socket ready for reads or writes
        unit: ns
      outgoing-byte-rate:
        desc: The average number of outgoing bytes sent per second to all servers
        unit: By
      request-latency-avg:
        desc: The average request latency
        unit: ms
      request-rate:
        desc: The average number of requests sent per second
        unit: '{request}'
      response-rate:
        desc: Responses received per second
        unit: '{response}'

  # per topic metrics
  - bean: kafka.producer:client-id=*,topic=*,type=producer-topic-metrics
    metricAttribute:
      client-id: param(client-id)
      topic: param(topic)
    prefix: kafka.producer.
    type: gauge
    mapping:
      byte-rate:
        desc: The average number of bytes sent per second for a topic
        unit: By
      compression-rate:
        desc: The average compression rate of record batches for a topic, defined as the average ratio of the compressed batch size divided by the uncompressed size
        unit: '{ratio}'
      record-error-rate:
        desc: The average per-second number of record sends that resulted in errors for a topic
        unit: '{record}'
      record-retry-rate:
        desc: The average per-second number of retried record sends for a topic
        unit: '{record}'
      record-send-rate:
        desc: The average number of records sent per second for a topic
        unit: '{record}'
