Skip to content

Commit

Permalink
Add function to analyse used labels, and not just used metrics.
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Wilkie <[email protected]>
  • Loading branch information
tomwilkie committed Jan 6, 2022
1 parent 3048e55 commit ea6d96c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/commands/analyse.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package commands

import (
"encoding/json"
"os"

log "github.com/sirupsen/logrus"
"gopkg.in/alecthomas/kingpin.v2"
)

Expand Down Expand Up @@ -91,4 +95,12 @@ func (cmd *AnalyseCommand) Register(app *kingpin.Application) {
ruleFileAnalyseCmd.Flag("output", "The path for the output file").
Default("metrics-in-ruler.json").
StringVar(&rfCmd.outputFile)

analyseCmd.Command("queries", "Extract the used metrics and labels from queries fed in on stdin.").Action(func(_ *kingpin.ParseContext) error {
metrics, err := processQueries(os.Stdin)
if err != nil {
log.Fatalf("failed to process queries: %v", err)
}
return json.NewEncoder(os.Stdout).Encode(metrics)
})
}

0 comments on commit ea6d96c

Please sign in to comment.