-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Promtail: Add metrics for journal target (#6105)
* Add metrics for journal target There are no metrics for the journal target yet, this adds two basic ones: - Total number of lines processed - Total number of errors processing lines (with a reason) Because of the way the journal works, tailing one file with many possible process writing to it, I chose note to expose counts per unit. * Add changelog entry * Fix compilation of (unsupported) journalmanager target on windows * Extract possible errors to constants & add tests
- Loading branch information
Showing
8 changed files
with
178 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
server: | ||
http_listen_port: 9080 | ||
grpc_listen_port: 0 | ||
|
||
positions: | ||
filename: /tmp/positions.yaml | ||
|
||
clients: | ||
- url: http://localhost:3100/loki/api/v1/push | ||
|
||
scrape_configs: | ||
- job_name: journal | ||
journal: | ||
max_age: 12h | ||
labels: | ||
job: systemd-journal | ||
relabel_configs: | ||
- source_labels: ['__journal__systemd_unit'] | ||
target_label: 'unit' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package journal | ||
|
||
import "github.com/prometheus/client_golang/prometheus" | ||
|
||
// Metrics holds a set of journal target metrics. | ||
type Metrics struct { | ||
reg prometheus.Registerer | ||
|
||
journalErrors *prometheus.CounterVec | ||
journalLines prometheus.Counter | ||
} | ||
|
||
const ( | ||
noMessageError = "no_message" | ||
emptyLabelsError = "empty_labels" | ||
) | ||
|
||
// NewMetrics creates a new set of journal target metrics. If reg is non-nil, the | ||
// metrics will be registered. | ||
func NewMetrics(reg prometheus.Registerer) *Metrics { | ||
var m Metrics | ||
m.reg = reg | ||
|
||
m.journalErrors = prometheus.NewCounterVec(prometheus.CounterOpts{ | ||
Namespace: "promtail", | ||
Name: "journal_target_parsing_errors_total", | ||
Help: "Total number of parsing errors while reading journal messages", | ||
}, []string{"error"}) | ||
m.journalLines = prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: "promtail", | ||
Name: "journal_target_lines_total", | ||
Help: "Total number of successful journal lines read", | ||
}) | ||
|
||
if reg != nil { | ||
reg.MustRegister( | ||
m.journalErrors, | ||
m.journalLines, | ||
) | ||
} | ||
|
||
return &m | ||
} |
Oops, something went wrong.