The node_exporter is the most widely used and known metrics collector (and exporter) in the Prometheus (and surrounding) project. It exposes a lot of system metrics which can be scraped by Prometheus, stored into a TSMD and then used in observability dashboards.
node_exporter runs as a process and (by default) listens on tcp/9100. Besides node_exporter there are many other Prometheus exporters available, all with their own (configurable) listening port. This has an effect on the Prometheus scraping configuration and security (firewall ports). Maybe there's an easier way?
Grafana Alloy has an ambitious goal: Be an one-in-all OTLP-compatible observability daemon. It does metrics collection, acts as scraper (of its own collectors) and forwards the metrics to a destination endpoint. It is even capable of being the receiver of such metrics.
Let's focus on the exporters. As of writing this article, Alloy's binary bundles 27 Prometheus exporters, which are named Prometheus components. As one would expect, the famous node_exporter is part of these bundled exporters, is however called "unix" (prometheus.exporter.unix).
Let's use the official documentation example to configure Alloy to run the embedded unix exporter:
ck@linux ~ $ cat /etc/alloy/config.alloy
// Sample config for Alloy.
//
// For a full configuration reference, see https://grafana.com/docs/alloy
logging {
level = "warn"
}
prometheus.exporter.unix "localhost" {
include_exporter_metrics = true
}
prometheus.scrape "node" {
targets = prometheus.exporter.unix.localhost.targets
forward_to = [
// although empty, need to define or alloy will not be happy
]
}
Attempting to explain this configuration:
According to the Grafana documentation, this should be enough to start collecting the system metrics using the node_exporter a.k.a. prometheus.exporter.unix.
Lets verify if we can access these metrics now:
ck@linux ~ $ curl -s http://localhost:12345/metrics|grep -c node
1
Only one line was returned from Alloy metrics, grepping for the "node" string. Umm, that surely can't be right.
Comparing with the metrics from a standalone running node_exporter process reveals many more metrics:
ck@linux ~ $ curl -s http://localhost:9100/metrics|grep -c node
2724
Does it mean the Node/Unix exporter metrics can't be scraped or read from Alloy directly?
As it turns out, each Alloy component exposes its metrics under a very specific path inside the Alloy API. As Alloy is listening on port 12345 (funny, huh?), a curl request to localhost:12345 should reveal the metrics. The tricky part is how to know the API path for each component - as this information can nowhere be found in the documentation!
To access the prometheus.exporter.unix exporter metrics, we need to request the following API URL:
http://localhost:12345/api/v0/component/prometheus.exporter.unix.LABEL/metrics
Where LABEL is obviously our unique label name (localhost), defined in the Alloy configuration. Therefore:
ck@linux ~ $ curl -s localhost:12345/api/v0/component/prometheus.exporter.unix.localhost/metrics |grep -c node
2537
Eureka! We got 2537 lines with the string "node" back!
Comparing with the standalone node_exporter metrics we're more or less in the same range, even though there are less lines. This could also be because of the version of the bundled node_exporter or more comments/descriptions in the output.
So by using the component API path, we are able to locally read the metrics of the Alloy bundled Prometheus exporters; and verify the exporters are working and collecting data.
No comments yet.
AWS Android Ansible Apache Apple Atlassian BSD Backup Bash Bluecoat CMS Chef Cloud Coding Consul Containers CouchDB DB DNS Database Databases Docker ELK Elasticsearch Filebeat FreeBSD Galera Git GlusterFS Grafana Graphics HAProxy HTML Hacks Hardware Icinga Influx Internet Java KVM Kibana Kodi Kubernetes LVM LXC Linux Logstash Mac Macintosh Mail MariaDB Minio MongoDB Monitoring Multimedia MySQL NFS Nagios Network Nginx OSSEC OTRS Observability Office OpenSearch PGSQL PHP Perl Personal PostgreSQL Postgres PowerDNS Proxmox Proxy Python Rancher Rant Redis Roundcube SSL Samba Seafile Security Shell SmartOS Solaris Surveillance Systemd TLS Tomcat Ubuntu Unix VMWare VMware Varnish Virtualization Windows Wireless Wordpress Wyse ZFS Zoneminder