-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Render agent status using status component (#22115)
Render agent status using status component Co-authored-by: KevinFairise2 <kevin.fairise@datadoghq.com>
- Loading branch information
1 parent
664558d
commit 1f83d84
Showing
114 changed files
with
4,757 additions
and
377 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
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,74 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2023-present Datadog, Inc. | ||
|
||
// Package demultiplexerimpl defines the aggregator demultiplexer | ||
package demultiplexerimpl | ||
|
||
import ( | ||
"embed" | ||
"encoding/json" | ||
"expvar" | ||
"io" | ||
|
||
checkstats "github.com/DataDog/datadog-agent/pkg/collector/check/stats" | ||
|
||
"github.com/DataDog/datadog-agent/comp/core/log" | ||
"github.com/DataDog/datadog-agent/comp/core/status" | ||
) | ||
|
||
//go:embed status_templates | ||
var templatesFS embed.FS | ||
|
||
type demultiplexerStatus struct { | ||
Log log.Component | ||
} | ||
|
||
func (d demultiplexerStatus) getStatusInfo() map[string]interface{} { | ||
stats := make(map[string]interface{}) | ||
|
||
d.populateStatus(stats) | ||
|
||
return stats | ||
} | ||
|
||
func (d demultiplexerStatus) populateStatus(stats map[string]interface{}) { | ||
aggregatorStatsJSON := []byte(expvar.Get("aggregator").String()) | ||
aggregatorStats := make(map[string]interface{}) | ||
json.Unmarshal(aggregatorStatsJSON, &aggregatorStats) //nolint:errcheck | ||
stats["aggregatorStats"] = aggregatorStats | ||
s, err := checkstats.TranslateEventPlatformEventTypes(stats["aggregatorStats"]) | ||
if err != nil { | ||
d.Log.Debugf("failed to translate event platform event types in aggregatorStats: %s", err.Error()) | ||
} else { | ||
stats["aggregatorStats"] = s | ||
} | ||
} | ||
|
||
// Name returns the name | ||
func (d demultiplexerStatus) Name() string { | ||
return "Aggregator" | ||
} | ||
|
||
// Section return the section | ||
func (d demultiplexerStatus) Section() string { | ||
return "aggregator" | ||
} | ||
|
||
// JSON populates the status map | ||
func (d demultiplexerStatus) JSON(_ bool, stats map[string]interface{}) error { | ||
d.populateStatus(stats) | ||
|
||
return nil | ||
} | ||
|
||
// Text renders the text output | ||
func (d demultiplexerStatus) Text(_ bool, buffer io.Writer) error { | ||
return status.RenderText(templatesFS, "aggregator.tmpl", buffer, d.getStatusInfo()) | ||
} | ||
|
||
// HTML renders the html output | ||
func (d demultiplexerStatus) HTML(_ bool, buffer io.Writer) error { | ||
return status.RenderHTML(templatesFS, "aggregatorHTML.tmpl", buffer, d.getStatusInfo()) | ||
} |
52 changes: 52 additions & 0 deletions
52
comp/aggregator/demultiplexer/demultiplexerimpl/status_templates/aggregator.tmpl
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,52 @@ | ||
{{- with .aggregatorStats }} | ||
{{- if .ChecksMetricSample }} | ||
Checks Metric Sample: {{humanize .ChecksMetricSample}} | ||
{{- end }} | ||
{{- if .DogstatsdMetricSample}} | ||
Dogstatsd Metric Sample: {{humanize .DogstatsdMetricSample}} | ||
{{- end }} | ||
{{- if .Event}} | ||
Event: {{humanize .Event}} | ||
{{- end }} | ||
{{- if .EventsFlushed}} | ||
Events Flushed: {{humanize .EventsFlushed}} | ||
{{- end }} | ||
{{- if .EventsFlushErrors}} | ||
Events Flush Errors: {{humanize .EventsFlushErrors}} | ||
{{- end }} | ||
{{- if .NumberOfFlush}} | ||
Number Of Flushes: {{humanize .NumberOfFlush}} | ||
{{- end }} | ||
{{- if .SeriesFlushed}} | ||
Series Flushed: {{humanize .SeriesFlushed}} | ||
{{- end }} | ||
{{- if .SeriesFlushErrors}} | ||
Series Flush Errors: {{humanize .SeriesFlushErrors}} | ||
{{- end }} | ||
{{- if .ServiceCheck}} | ||
Service Check: {{humanize .ServiceCheck}} | ||
{{- end }} | ||
{{- if .ServiceCheckFlushed}} | ||
Service Checks Flushed: {{humanize .ServiceCheckFlushed}} | ||
{{- end }} | ||
{{- if .ServiceCheckFlushErrors}} | ||
Service Checks Flush Errors: {{humanize .ServiceCheckFlushErrors}} | ||
{{- end }} | ||
{{- if .SketchesFlushed}} | ||
Sketches Flushed: {{humanize .SketchesFlushed}} | ||
{{- end }} | ||
{{- if .SketchesFlushErrors}} | ||
Sketches Flush Errors: {{humanize .SketchesFlushErrors}} | ||
{{- end }} | ||
{{- if .ChecksHistogramBucketMetricSample }} | ||
Checks Histogram Bucket Metric Sample: {{humanize .ChecksHistogramBucketMetricSample}} | ||
{{- end }} | ||
{{- if .EventPlatformEvents }} | ||
{{- range $k, $v := .EventPlatformEvents }} | ||
{{ $k }}: {{humanize $v}} | ||
{{- end }} | ||
{{- end }} | ||
{{- if .HostnameUpdate}} | ||
Hostname Update: {{humanize .HostnameUpdate}} | ||
{{- end }} | ||
{{- end }} |
Oops, something went wrong.