Telegraf logparser, prometheus_client drops metrics



According to this suggestion Telegraf logparser output prometheus_client help needed

I configured telegraf

  files = ["/var/log/mail.log"]
  from_beginning = false
      patterns = ["%{SYSLOGAMAVIS} \\([0-9\\-]+\\) \\w+ %{WORD:statusname} %{GREEDYDATA}"]
      measurement = "spamassassin_mail"

      custom_patterns = '''
          AMAVISPROG amavis

          timezone = "Local"
        value = "1"

  namepass = ["spamassassin_mail"]
    integer = ["value"]
    tag = ["statusname"]

  namepass = ["spamassassin_mail"]
  drop_original = true
  period = "30s"
  stats = ["sum"]

Log line

Jul  8 01:43:35 mx amavis[12227]: (12227-18) Passed CLEAN {RelayedInbound}, [x.x.x.x]:42538 [y.y.y.y] <> -> <>, Queue-ID: 53662B08A94C, Message-ID: <>, mail_id: lUsZ53IlsaJo, Hits: 4.55, size: 39227, queued_as: 54BE4B08A94D, 1927 ms

Start telegraf
Wait message in mail.log and view the output from telegraf

curl -s | grep spam
spamassassin_mail_value_sum{host="mx",path="/var/log/mail.log",statusname="CLEAN"} 3

But in a short time this result disappears from telegraf metrics due to the next expected log message and output starts from the beginning

spamassassin_mail_value_sum{host="mx",path="/var/log/mail.log",statusname="CLEAN"} 1

How to fix this, i need growing counter?


I think we would need a new processor to turn reseting counters into non-reseting counters. You could open a new issue on the Telegraf issue tracker.