[pkg-go] Bug#886893: Bug#886893: document how to hook into prometheus

Martina Ferrari tina at tina.pm
Sat May 16 21:21:33 BST 2020


Hi Antoine!

On 11/01/2018 01:37, Antoine Beaupre wrote:
> So I have figured out that mtail can send out metrics as Prometheus
> wants them, under /prometheus. But I did this mostly by having my hand
> held by the maintainer - there is very little documentation in the
> Debian package itself on how to configure it.

I am interesting in knowing more about this. How did you configure that
behaviour?

> It would be nice to have a simple README.Debian file that would say
> how to deploy config files (and where) and how to hook it into
> Prometheus.
Definitely. I have not done it in the past, because I could not find a
way that was generic and simple enough. My usual configuration for mtail
requires a bunch of rewrite rules, and these are dependent on the mtail
programs loaded. My configuration for scraping mtail with apache and
postfix log scrapers looks like this:

scrape_configs:
  - job_name: 'mtail'
    static_configs:
      - targets: ['foo.example.org:3903']
    metric_relabel_configs:
      - source_labels: [prog, server_port]
        regex: 'apache_metrics.mtail;(.*)'
        target_label: instance
        replacement: ${1}
      - source_labels: [prog, server_port]
        regex: 'apache_metrics.mtail;.*'
        target_label: job
        replacement: apache
      - source_labels: [prog]
        regex: 'apache_metrics.mtail'
        target_label: server_port
        replacement: ''
      - source_labels: [prog]
        regex: 'apache_metrics.mtail'
        target_label: prog
        replacement: ''

      - source_labels: [prog]
        regex: 'postfix.mtail'
        target_label: job
        replacement: 'postfix'
      - source_labels: [prog, instance]
        regex: 'postfix.mtail;(.*):3903'
        target_label: instance
        replacement: '$1:25'
      - source_labels: [prog]
        regex: 'postfix.mtail'
        target_label: prog
        replacement: ''
      - regex: 'exported_instance'
        action: labeldrop


These use the "prog" label to identify the source of data, and rewrites
the "instance" label so it looks like it is an exporter running in the
same port as an apache vhost or postfix.



-- 
Martina Ferrari (Tina)



More information about the Pkg-go-maintainers mailing list