这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.
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
15 changes: 15 additions & 0 deletions cmd/bosun/search/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,21 @@ func (s *Search) TagKeysByMetric(Metric string) []string {
return r
}

func (s *Search) MetricsWithTagKeys() map[string][]string {
metricToKeys := make(map[string][]string)
searchResult := s.Read.Tagk.Copy()
for metric, v := range searchResult {
keys := make([]string, len(v))
i := 0
for tK := range v {
keys[i] = tK
i++
}
metricToKeys[metric] = keys
}
return metricToKeys
}

func (s *Search) tagValuesByMetricTagKey(Metric, Tagk string, since time.Duration) []string {
var t int64
if since > 0 {
Expand Down
5 changes: 5 additions & 0 deletions cmd/bosun/web/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ func MetricsByTagPair(t miniprofiler.Timer, w http.ResponseWriter, r *http.Reque
return values, nil
}

func MetricsWithTagKeys(t miniprofiler.Timer, w http.ResponseWriter, r *http.Request) (interface{}, error) {
values := schedule.Search.MetricsWithTagKeys()
return values, nil
}

func TagValuesByTagKey(t miniprofiler.Timer, w http.ResponseWriter, r *http.Request) (interface{}, error) {
vars := mux.Vars(r)
tagk := vars["tagk"]
Expand Down
1 change: 1 addition & 0 deletions cmd/bosun/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func Listen(listenAddr string, devMode bool, tsdbHost string) error {
router.Handle("/api/metadata/put", JSON(PutMetadata))
router.Handle("/api/metric", JSON(UniqueMetrics))
router.Handle("/api/metric/{tagk}/{tagv}", JSON(MetricsByTagPair))
router.Handle("/api/metric/tagkey", JSON(MetricsWithTagKeys))
router.Handle("/api/rule", JSON(Rule))
router.HandleFunc("/api/shorten", Shorten)
router.Handle("/api/silence/clear", JSON(SilenceClear))
Expand Down
4 changes: 4 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ Returns dashboard-ready data for all hosts.

Returns the metrics that have been relayed through bosun.

### /api/metric/tagkey

Returns the metrics that have been relayed through bosun and their associated tag keys.

### /api/metric/{tagk}/{tagv}

Returns the metrics that are available for the specified tagk/tagv pair. For
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.