Memcached Exporter

grafana-agent内置了memcached_exporter,来采集memcached的运行指标。

当前grafana-agent只支持配置一个memcached的地址来采集其metrics数据。如果您需要采集多个memcached的metrics指标,那么需要启动多个grafana-agent实例,并通过relabel_configs来区分来自不同memcached server的metrics。

配置并启用memcached_exporter

  1. memcached_exporter:
  2. enabled: true
  3. memcached_address: memcached-a:53
  4. relabel_configs:
  5. - source_labels: [__address__]
  6. target_label: instance
  7. replacement: memcached-a

采集的关键指标列表

  1. memcached_commands_total : sum (memcached_commands_total{instance=~"$node", command="set"}) / sum (memcached_commands_total{instance=~"$node", command="get"})
  2. memcached_commands_total : sum (memcached_commands_total{instance=~"$node", status="miss"}) / sum (memcached_commands_total{instance=~"$node"})
  3. memcached_commands_total : sum (memcached_commands_total{instance=~"$node"}) by (command)
  4. memcached_current_bytes : sum(memcached_current_bytes{instance=~"$node"}) / sum(memcached_limit_bytes{instance=~"$node"})
  5. memcached_current_connections : sum (memcached_current_connections{instance=~"$node"}) by (instance)
  6. memcached_current_items : sum (memcached_current_items{instance=~"$node"})
  7. memcached_items_evicted_total : sum(memcached_items_evicted_total{instance=~"$node"})
  8. memcached_items_reclaimed_total : sum(memcached_items_reclaimed_total{instance=~"$node"})
  9. memcached_read_bytes_total : sum(irate(memcached_read_bytes_total{instance=~"$node"}[5m]))
  10. memcached_written_bytes_total : irate(memcached_written_bytes_total{instance=~"$node"}[10m])

完整地配置项说明

  1. # Enables the memcached_exporter integration, allowing the Agent to automatically
  2. # collect system metrics from the configured memcached server address
  3. [enabled: <boolean> | default = false]
  4. # Sets an explicit value for the instance label when the integration is
  5. # self-scraped. Overrides inferred values.
  6. #
  7. # The default value for this integration is inferred from
  8. # memcached_address.
  9. [instance: <string>]
  10. # Automatically collect metrics from this integration. If disabled,
  11. # the memcached_exporter integration will be run but not scraped and thus not
  12. # remote-written. Metrics for the integration will be exposed at
  13. # /integrations/memcached_exporter/metrics and can be scraped by an external
  14. # process.
  15. [scrape_integration: <boolean> | default = <integrations_config.scrape_integrations>]
  16. # How often should the metrics be collected? Defaults to
  17. # prometheus.global.scrape_interval.
  18. [scrape_interval: <duration> | default = <global_config.scrape_interval>]
  19. # The timeout before considering the scrape a failure. Defaults to
  20. # prometheus.global.scrape_timeout.
  21. [scrape_timeout: <duration> | default = <global_config.scrape_timeout>]
  22. # Allows for relabeling labels on the target.
  23. relabel_configs:
  24. [- <relabel_config> ... ]
  25. # Relabel metrics coming from the integration, allowing to drop series
  26. # from the integration that you don't care about.
  27. metric_relabel_configs:
  28. [ - <relabel_config> ... ]
  29. # How frequent to truncate the WAL for this integration.
  30. [wal_truncate_frequency: <duration> | default = "60m"]
  31. # Monitor the exporter itself and include those metrics in the results.
  32. [include_exporter_metrics: <bool> | default = false]
  33. #
  34. # Exporter-specific configuration options
  35. #
  36. # Address of the memcached server in host:port form.
  37. [memcached_address: <string> | default = "localhost:53"]
  38. # Timeout for connecting to memcached.
  39. [timeout: <duration> | default = "1s"]