0
votes

I'm in the process of writing a Prometheus Exporter in Go to expose metrics pushed from AIX severs. The AIX servers push their metrics (in json) to a central listener (the exporter program) that converts them to standard Prometheus metrics and exposes them for scraping.

The issue I have is that the hostname for the metrics is extracted from the pushed json. I store this as a label in each metric. E.g. njmon_memory_free{lpar="myhostname"}. While this works, it's less than ideal as there doesn't seem to be a way to relabel this to the usual instance label (njmon_memory_free{instance="myhostname"}. The Prometheus relabelling happens before the scrape so the lpar label isn't there to be relabelled.

One option seems to be to rewrite the exporter so that the Prometheus server probes defined targets, each target being the lpar. In order for that to work, I'd need a means to filter the stored metrics by lpar so only metrics relating to the target/lpar are returned. Is this a practical solution or am I forced to create a dedicated listener or url for every lpar?

1
As I understand you are the author of this exporter. You could use "instance" label in exporter, not "lpar". Also you may use "honor_labels: true" in Prometheus scrape_config.Sasha Golikov
That is not the recommended Prometheus architecture. Prom should scrape directly each of these AIX servers. If it did that, you would have no problems with correctly identifying the hostname. Is there a specific reason that makes it impossible to follow Prometheus recommendation ?marco.m
@marco.m There are a couple of reasons. * njmon is designed to push, not be scraped * The njmon json isn't formatted in a Prometheus compatible manner If Go and the required libraries compiled on AIX, I'd write the exporter in such as manner as to scrape each target individually but that may be some time away (or never).Steve Crook
Ah I see, though one. As much as I love Go, if that is not supported (or painful) on AIX, I would consider using another language to write an exporter to be installed on each node, configure this njmon to push locally to the exporter and finally configure Prometheus to scrape each single node. In my experience with Prometheus (I like it a lot), it is better to go with the flow than attempting to shoehorn something.marco.m
@SashaGolikov your suggestion worked perfectly. I appreciate this isn't the usual Prometheus architecture but it works for now and required only minimal changes on the AIX systems being monitored. Thanks for the assistance.Steve Crook

1 Answers

1
votes

So I'm fixing my answer given in comments, due it was helpfull to author.

  • Use "instance" label in exporter, not "lpar" (change exporter code)
  • Use "honor_labels: true" in Prometheus scrape_config