Skip to content

Commit

Permalink
Add support for new/renamed fields in syslog-ng 3.20
Browse files Browse the repository at this point in the history
  • Loading branch information
brandond committed Apr 25, 2019
1 parent c9f33f1 commit 2f65768
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Help on flags:
--log.format="logger:stderr" Set the log target and format. Example: "logger:syslog?appname=bob&local=7" or "logger:stdout?json=true"
```

Tested with syslog-ng 3.5.6
Tested with syslog-ng 3.5.6 and 3.20.1


# Using Docker
Expand Down
26 changes: 23 additions & 3 deletions syslog_ng_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type Exporter struct {
dstProcessed *prometheus.Desc
dstDropped *prometheus.Desc
dstStored *prometheus.Desc
dstWritten *prometheus.Desc
dstMemory *prometheus.Desc
up *prometheus.Desc
scrapeFailures prometheus.Counter
}
Expand Down Expand Up @@ -66,12 +68,22 @@ func NewExporter(path string) *Exporter {
nil),
dstDropped: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "destination_messages_dropped", "total"),
"Number of messages dropped by this destination.",
"Number of messages dropped by this destination due to store overflow.",
[]string{"type", "id", "destination"},
nil),
dstStored: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "destination_messages_stored", "total"),
"Number of messages stored by this destination.",
"Number of messages currently stored for this destination.",
[]string{"type", "id", "destination"},
nil),
dstWritten: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "destination_messages_written", "total"),
"Number of messages successfully written by this destination.",
[]string{"type", "id", "destination"},
nil),
dstMemory: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "destination_bytes_stored", "total"),
"Bytes of memory currently used to store messages for this destination.",
[]string{"type", "id", "destination"},
nil),
up: prometheus.NewDesc(
Expand All @@ -92,6 +104,8 @@ func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
ch <- e.dstProcessed
ch <- e.dstDropped
ch <- e.dstStored
ch <- e.dstWritten
ch <- e.dstMemory
ch <- e.up
e.scrapeFailures.Describe(ch)
}
Expand Down Expand Up @@ -167,9 +181,15 @@ func (e *Exporter) collect(ch chan<- prometheus.Metric) error {
case "processed":
ch <- prometheus.MustNewConstMetric(e.dstProcessed, prometheus.CounterValue,
stat.value, stat.objectType, stat.id, stat.instance)
case "stored":
case "written":
ch <- prometheus.MustNewConstMetric(e.dstWritten, prometheus.CounterValue,
stat.value, stat.objectType, stat.id, stat.instance)
case "stored", "queued":
ch <- prometheus.MustNewConstMetric(e.dstStored, prometheus.GaugeValue,
stat.value, stat.objectType, stat.id, stat.instance)
case "memory_usage":
ch <- prometheus.MustNewConstMetric(e.dstMemory, prometheus.GaugeValue,
stat.value, stat.objectType, stat.id, stat.instance)
}
}
}
Expand Down

0 comments on commit 2f65768

Please sign in to comment.