Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Refactor & rename ratelimit metrics #2890

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contrib/upgrade-notes/latest.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ Depending on your setup, changes listed here might require a manual intervention

### Metrics

* TBD
* `tetragon_ratelimit_dropped_total` metric is renamed to `tetragon_export_ratelimit_events_dropped_total`
8 changes: 4 additions & 4 deletions docs/content/en/docs/reference/metrics.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func (e *Exporter) Start() error {
func (e *Exporter) Send(event *tetragon.GetEventsResponse) error {
if e.rateLimiter != nil && !e.rateLimiter.Allow() {
e.rateLimiter.Drop()
rateLimitDropped.Inc()
return nil
}

Expand Down
16 changes: 13 additions & 3 deletions pkg/exporter/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,22 @@ var (
Name: "events_last_exported_timestamp",
Help: "Timestamp of the most recent event to be exported",
})

rateLimitDropped = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: consts.MetricsNamespace,
Name: "export_ratelimit_events_dropped_total",
Help: "Number of events dropped on export due to rate limiting",
ConstLabels: nil,
})
)

func RegisterMetrics(group metrics.Group) {
group.MustRegister(eventsExportedTotal)
group.MustRegister(eventsExportedBytesTotal)
group.MustRegister(eventsExportTimestamp)
group.MustRegister(
eventsExportedTotal,
eventsExportedBytesTotal,
eventsExportTimestamp,
rateLimitDropped,
)
}

func newExportedBytesCounterWriter(w io.Writer, c prometheus.Counter) io.Writer {
Expand Down
23 changes: 0 additions & 23 deletions pkg/metrics/ratelimitmetrics/ratelimitmetrics.go

This file was deleted.

3 changes: 0 additions & 3 deletions pkg/metricsconfig/healthmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/cilium/tetragon/pkg/metrics/opcodemetrics"
"github.com/cilium/tetragon/pkg/metrics/policyfiltermetrics"
"github.com/cilium/tetragon/pkg/metrics/policystatemetrics"
"github.com/cilium/tetragon/pkg/metrics/ratelimitmetrics"
"github.com/cilium/tetragon/pkg/metrics/watchermetrics"
"github.com/cilium/tetragon/pkg/observer"
"github.com/cilium/tetragon/pkg/process"
Expand Down Expand Up @@ -81,8 +80,6 @@ func registerHealthMetrics(group metrics.Group) {
// tracing metrics
tracing.RegisterMetrics(group)
group.ExtendInit(tracing.InitMetrics)
// rate limit metrics
ratelimitmetrics.RegisterMetrics(group)
// exporter metrics
exporter.RegisterMetrics(group)
// cgrup rate metrics
Expand Down
2 changes: 0 additions & 2 deletions pkg/ratelimit/ratelimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/cilium/tetragon/api/v1/tetragon"
"github.com/cilium/tetragon/pkg/encoder"
"github.com/cilium/tetragon/pkg/logger"
"github.com/cilium/tetragon/pkg/metrics/ratelimitmetrics"
"github.com/cilium/tetragon/pkg/reader/node"
"golang.org/x/time/rate"
"google.golang.org/protobuf/types/known/timestamppb"
Expand Down Expand Up @@ -78,5 +77,4 @@ func (r *RateLimiter) reportRateLimitInfo(encoder encoder.EventEncoder) {

func (r *RateLimiter) Drop() {
atomic.AddUint64(&r.dropped, 1)
ratelimitmetrics.RateLimitDropped.Inc()
}
Loading