Skip to content

Different ports for different sources #236

@AlexSSP

Description

@AlexSSP

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions