-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this is useful to figure out how much data is being exported and if the log pipeline is behind in processing the incoming events. Signed-off-by: Chance Zibolski <[email protected]>
- Loading branch information
Showing
5 changed files
with
76 additions
and
1 deletion.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,56 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Authors of Cilium | ||
|
||
package exporter | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/cilium/tetragon/pkg/metrics/consts" | ||
"github.com/prometheus/client_golang/prometheus" | ||
) | ||
|
||
var ( | ||
eventsExportedTotal = prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: consts.MetricsNamespace, | ||
Name: "events_exported_total", | ||
Help: "Total number of events exported", | ||
}) | ||
|
||
eventsExportedBytesTotal = prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: consts.MetricsNamespace, | ||
Name: "events_exported_bytes_total", | ||
Help: "Number of bytes exported for events", | ||
}) | ||
|
||
eventsExportTimestamp = prometheus.NewGauge(prometheus.GaugeOpts{ | ||
Namespace: consts.MetricsNamespace, | ||
Name: "events_last_exported_timestamp", | ||
Help: "Timestamp of the most recent event to be exported", | ||
}) | ||
) | ||
|
||
func InitMetrics(registry *prometheus.Registry) { | ||
registry.MustRegister(eventsExportedTotal) | ||
registry.MustRegister(eventsExportedBytesTotal) | ||
registry.MustRegister(eventsExportTimestamp) | ||
} | ||
|
||
func newExportedBytesCounterWriter(w io.Writer, c prometheus.Counter) io.Writer { | ||
return byteCounterWriter{Writer: w, bytesWritten: c} | ||
} | ||
|
||
type byteCounterWriter struct { | ||
io.Writer | ||
bytesWritten prometheus.Counter | ||
} | ||
|
||
func (w byteCounterWriter) Write(p []byte) (int, error) { | ||
n, err := w.Writer.Write(p) | ||
w.bytesWritten.Add(float64(n)) | ||
return n, err | ||
} | ||
|
||
func NewExportedBytesTotalWriter(w io.Writer) io.Writer { | ||
return newExportedBytesCounterWriter(w, eventsExportedBytesTotal) | ||
} |
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