fluent-plugin-prometheus icon indicating copy to clipboard operation
fluent-plugin-prometheus copied to clipboard

Different ports for different sources

Open AlexSSP opened this issue 5 months ago • 0 comments

How can I сonfigure expose different ports for different sources? For example:

espose port 24231 for tail file /var/log/nginx/access1.log

<source>
    @type prometheus_tail_monitor
</source>

<source>
    @type prometheus
    port 24231
</source>

<source>
    @type tail
    <parse>
    @type regexp
    expression /^(?<remote>[^ ]*) \[(?<geoip>[^ ]*)\] (?<host>[^ ]*) (?<user>[^ ]*) \[(?<time>[^\]]*)\] \"(?<method>\w+)(?:\s+(?<path>[^\"]*?)(?:\s+\S*)?)?\" (?<status_code>[^ ]*) (?<size>[^ ]*)(?:\s"(?<referer>[^\"]*)") "(?<agent>[^\"]*)" (?<urt>[^ ]*)$/
        time_format %d/%b/%Y:%H:%M:%S %z
        keep_time_key true
        types size:integer,reqtime:float,uct:float,uht:float,urt:float
    </parse>
    tag nginx1.default
    path /var/log/nginx/access1.log
    pos_file /tmp/fluent_nginx1.pos
</source>

<filter nginx1.default>
    @type prometheus

  <metric>
    name nginx_size_bytes_total
    type counter
    desc nginx bytes sent
    <labels>
      site default
    </labels>
    key size
  </metric>

</filter>

and espose port 24232 for tail file /var/log/nginx/access2.log

<source>
    @type prometheus_tail_monitor
</source>

<source>
    @type prometheus
    port 24232
</source>

<source>
    @type tail
    <parse>
    @type regexp
    expression /^(?<remote>[^ ]*) \[(?<geoip>[^ ]*)\] (?<host>[^ ]*) (?<user>[^ ]*) \[(?<time>[^\]]*)\] \"(?<method>\w+)(?:\s+(?<path>[^\"]*?)(?:\s+\S*)?)?\" (?<status_code>[^ ]*) (?<size>[^ ]*)(?:\s"(?<referer>[^\"]*)") "(?<agent>[^\"]*)" (?<urt>[^ ]*)$/
        time_format %d/%b/%Y:%H:%M:%S %z
        keep_time_key true
        types size:integer,reqtime:float,uct:float,uht:float,urt:float
    </parse>
    tag nginx2.default
    path /var/log/nginx/access2.log
    pos_file /tmp/fluent_nginx2.pos
</source>

<filter nginx2.default>
    @type prometheus

  <metric>
    name nginx_size_bytes_total
    type counter
    desc nginx bytes sent
    <labels>
      site default
    </labels>
    key size
  </metric>

</filter>

I want to see metric from file /var/log/nginx/access1.log in http://localhost:24231/metrics and metric from file /var/log/nginx/access2.log in http://localhost:24232/metrics

AlexSSP avatar Jul 01 '25 07:07 AlexSSP