Hi all,
I am trying out the Metricbeat Prometheus collector module with the two new options in 7.7; use_types
and rate_counters
; https://www.elastic.co/guide/en/beats/metricbeat/7.7/metricbeat-metricset-prometheus-collector.html
While the Histogram metrics are stored in ElasticSearch as documented, the Counter information is not. Namely, there is no separate rate field.
Here is what an indexed metric looks like:
{
"_index": "metricbeat-7.7.1-2020.06.08-000001",
"_type": "_doc",
"_id": "vzqzlnIB-vP0G_z2A1K5",
"_version": 1,
"_score": null,
"_source": {
"@timestamp": "2020-06-09T01:30:12.793Z",
"prometheus": {
"method_duration": {
"histogram": {
"counts": [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"values": [
0.0025,
0.0075,
0.0175,
0.037500000000000006,
0.0625,
0.0875,
0.175,
0.375,
0.625,
0.875,
1.75,
3.75,
6.25,
8.75,
12.5
]
}
},
"method_call_total": {
"value": 161
},
"labels": {
"job": "prometheus",
"method_name": "run",
"instance": "prometheus-test-service:8081"
},
"method_duration_created": {
"value": 1591665413.6988633
},
"method_call_created": {
"value": 1591665413.6987088
}
},
"metricset": {
"period": 5000,
"name": "collector"
},
"service": {
"type": "prometheus",
"address": "prometheus-test-service:8081"
},
"event": {
"module": "prometheus",
"duration": 14211000,
"dataset": "prometheus.collector"
},
"ecs": {
"version": "1.5.0"
},
"host": {
"name": "d0ab35b86d7a"
},
"agent": {
"version": "7.7.1",
"type": "metricbeat",
"ephemeral_id": "1e80477c-75e3-4001-b80a-88421bc48b3f",
"hostname": "d0ab35b86d7a",
"id": "d8079cbc-5971-46ce-b8d5-c18500d6b484"
}
},
"fields": {
"@timestamp": [
"2020-06-09T01:30:12.793Z"
]
},
"sort": [
1591666212793
]
}
For reference, this is the output from the Prometheus exporter when I make a GET request to it.
# HELP method_call_total The number of times a method is called
# TYPE method_call_total counter
method_call_total{method_name="run"} 227.0
# HELP method_call_created The number of times a method is called
# TYPE method_call_created gauge
method_call_created{method_name="run"} 1.5916654136987088e+09
# HELP method_duration The duration of the method
# TYPE method_duration histogram
method_duration_bucket{le="0.005",method_name="run"} 225.0
method_duration_bucket{le="0.01",method_name="run"} 226.0
method_duration_bucket{le="0.025",method_name="run"} 227.0
method_duration_bucket{le="0.05",method_name="run"} 227.0
method_duration_bucket{le="0.075",method_name="run"} 227.0
method_duration_bucket{le="0.1",method_name="run"} 227.0
method_duration_bucket{le="0.25",method_name="run"} 227.0
method_duration_bucket{le="0.5",method_name="run"} 227.0
method_duration_bucket{le="0.75",method_name="run"} 227.0
method_duration_bucket{le="1.0",method_name="run"} 227.0
method_duration_bucket{le="2.5",method_name="run"} 227.0
method_duration_bucket{le="5.0",method_name="run"} 227.0
method_duration_bucket{le="7.5",method_name="run"} 227.0
method_duration_bucket{le="10.0",method_name="run"} 227.0
method_duration_bucket{le="+Inf",method_name="run"} 227.0
method_duration_count{method_name="run"} 227.0
method_duration_sum{method_name="run"} 0.13504729981650598
(The counts don't line up as they were two separate metric requests).
The application is a Python application instrumented with the Python Prometheus client, https://github.com/prometheus/client_python
This is what the metricbeat.yml configuration that I am using looks like:
metricbeat.config.modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: false
processors:
- add_cloud_metadata: ~
- add_docker_metadata: ~
output.elasticsearch:
hosts: '${ELASTICSEARCH_HOSTS:elasticsearch:9200}'
username: '${ELASTICSEARCH_USERNAME:}'
password: '${ELASTICSEARCH_PASSWORD:}'
# Metrics collected from a Prometheus endpoint
metricbeat.modules:
- module: prometheus
period: 5s
hosts: ["prometheus-test-service:8081"]
metrics_path: /prometheus/metrics
use_types: true
rate_counters: true
Here is the docker-compose.yaml file I am using to run the ELK stack:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.7.1
container_name: elasticsearch
ports:
- 9200:9200
environment:
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "cluster.routing.allocation.disk.threshold_enabled=false"
- "http.cors.enabled=true"
- "http.cors.allow-origin=*"
- "http.cors.allow-headers=X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization"
- "http.cors.allow-credentials=true"
- "xpack.security.enabled=false"
healthcheck:
test: curl -s https://localhost:9200 >/dev/null; if [[ $$? == 52 ]]; then echo 0; else echo 1; fi
interval: 30s
timeout: 10s
retries: 5
kibana:
image: docker.elastic.co/kibana/kibana:7.7.1
container_name: kibana
ports:
- 5601:5601
depends_on:
- elasticsearch
healthcheck:
test: curl -s https://localhost:5601 >/dev/null; if [[ $$? == 52 ]]; then echo 0; else echo 1; fi
interval: 30s
timeout: 10s
retries: 5
metricbeat:
image: docker.elastic.co/beats/metricbeat:7.7.1
container_name: metricbeat
volumes:
# Mount the metricbeat config file that includes the prometheus exporter.
- ./metricbeat.yml:/usr/share/metricbeat/metricbeat.yml:ro
command: --strict.perms=false -e # -e flag to log to stderr and disable syslog/file output
depends_on:
- elasticsearch
- kibana
healthcheck:
test: metricbeat test config
interval: 30s
timeout: 15s
retries: 5
When I boot up Metricbeat, I do see these two logs:
metricbeat | 2020-06-09T01:50:00.671Z WARN [cfgwarn] collector/data.go:47 BETA: Prometheus 'use_types' setting is beta
metricbeat | 2020-06-09T01:50:00.671Z WARN [cfgwarn] collector/data.go:50 EXPERIMENTAL: Prometheus 'rate_counters' setting is experimental
Any help would be appreciated. Thank you!