## Prometheus Input Plugin Configuration

# input plugin that exports metrics
<source>
  @type prometheus
</source>

<source>
  @type monitor_agent
</source>

<source>
  @type forward
</source>

# input plugin that collects metrics from MonitorAgent
<source>
  @type prometheus_monitor
  <labels>
    host ${hostname}
  </labels>
</source>

# input plugin that collects metrics for output plugin
<source>
  @type prometheus_output_monitor
  <labels>
    host ${hostname}
  </labels>
</source>

# input plugin that collects metrics for in_tail plugin
<source>
  @type prometheus_tail_monitor
  <labels>
    host ${hostname}
  </labels>
</source>

## Nginx Access Log Configuration

<source>
  @type tail
  format nginx
  tag nginx
  path /var/log/nginx/access.log
  pos_file /tmp/fluent_nginx.pos
  types size:integer
</source>

<filter nginx>
  @type prometheus

  # You can use counter type with specifying a key,
  # and increments counter by the value
  <metric>
    name nginx_size_counter_bytes
    type counter
    desc nginx bytes sent
    key size
    <labels>
       host ${hostname}
       foo bar
    </labels>
  </metric>

  # You can use counter type without specifying a key
  # This just increments counter by 1
  <metric>
    name nginx_record_counts
    type counter
    desc the number of emited records
    <labels>
       host ${hostname}
    </labels>
  </metric>
</filter>

<match nginx>
  @type copy
  # for MonitorAgent sample
  <store>
    @id test_forward
    @type forward
    buffer_type memory
    flush_interval 1s
    max_retry_wait 2s
    <buffer>
    # max_retry_wait 10s
    flush_interval 1s
    # retry_type periodic
    disable_retry_limit
</buffer>
    # retry_limit 3
    disable_retry_limit
   <server>
     host 127.0.0.1
     port 20000
   </server>
  </store>
  <store>
    @type stdout
  </store>
</match>

## Nginx Proxy Log Configuration

<source>
  @type tail
  format ltsv
  tag nginx_proxy
  path /var/log/nginx/access_proxy.log
  pos_file /tmp/fluent_nginx_proxy.pos
  types size:integer,request_length:integer,bytes_sent:integer,body_bytes_sent:integer,request_time:float,upstream_response_time:float
</source>

<filter nginx_proxy>
  @type prometheus

  # common labels for all metrics
  <labels>
     host ${hostname}
     method ${request_method}
     status ${status}
  </labels>

  <metric>
    name nginx_proxy_request_length_total_bytes
    type counter
    desc nginx proxy request length bytes
    key request_length
  </metric>
  <metric>
    name nginx_proxy_bytes_sent_total_bytes
    type counter
    desc nginx proxy bytes sent
    key bytes_sent
  </metric>
  <metric>
    name nginx_proxy_request_duration_total_milliseconds
    type counter
    desc nginx proxy request time
    key request_time
  </metric>
  <metric>
    name nginx_proxy_upstream_response_duration_total_milliseconds
    type counter
    desc nginx proxy upstream response time
    key upstream_response_time
  </metric>
  <metric>
    name nginx_proxy_request_duration_milliseconds
    type summary
    desc nginx proxy request duration summary
    key request_time
  </metric>
  <metric>
    name nginx_proxy_upstream_duration_milliseconds
    type summary
    desc nginx proxy upstream response duration summary
    key upstream_response_time
  </metric>
</filter>

<match nginx_proxy>
  @type copy
  <store>
    @type stdout
  </store>
</match>
