Skip to content

Commit

Permalink
*: add admin grpc API
Browse files Browse the repository at this point in the history
  • Loading branch information
fabxc committed Jul 10, 2017
1 parent dc15a6f commit ccf9e62
Show file tree
Hide file tree
Showing 14 changed files with 2,701 additions and 113 deletions.
11 changes: 6 additions & 5 deletions cmd/prometheus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ func main() {
cfg.queryEngine.Logger = logger
var (
notifier = notifier.New(&cfg.notifier, logger)
targetManager = retrieval.NewTargetManager(localStorage, logger)
queryEngine = promql.NewEngine(localStorage, &cfg.queryEngine)
targetManager = retrieval.NewTargetManager(tsdb.Adapter(localStorage), logger)
queryEngine = promql.NewEngine(tsdb.Adapter(localStorage), &cfg.queryEngine)
ctx, cancelCtx = context.WithCancel(context.Background())
)

ruleManager := rules.NewManager(&rules.ManagerOptions{
Appendable: localStorage,
Appendable: tsdb.Adapter(localStorage),
Notifier: notifier,
QueryEngine: queryEngine,
Context: ctx,
Expand Down Expand Up @@ -318,7 +318,8 @@ func main() {
// to be canceled and ensures a quick shutdown of the rule manager.
defer cancelCtx()

go webHandler.Run()
errc := make(chan error)
go func() { errc <- webHandler.Run(ctx) }()

// Wait for reload or termination signals.
close(hupReady) // Unblock SIGHUP handler.
Expand All @@ -330,7 +331,7 @@ func main() {
logger.Warn("Received SIGTERM, exiting gracefully...")
case <-webHandler.Quit():
logger.Warn("Received termination request via web service, exiting gracefully...")
case err := <-webHandler.ListenError():
case err := <-errc:
logger.Errorln("Error starting web server, exiting gracefully:", err)
}

Expand Down
123 changes: 123 additions & 0 deletions documentation/dev/api/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"swagger": "2.0",
"info": {
"title": "prompb/rpc.proto",
"version": "version not set"
},
"schemes": [
"http",
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/admin/v1/tsdb/delete_series": {
"post": {
"summary": "DeleteSeries deletes data for a selection of series in a time range.",
"operationId": "DeleteSeries",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/prometheusSeriesDeleteResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/prometheusSeriesDeleteRequest"
}
}
],
"tags": [
"Admin"
]
}
},
"/admin/v1/tsdb/snapshot": {
"post": {
"summary": "Snapshot creates a snapshot of all current data into 'snapshots/\u003cdatetime\u003e-\u003crand\u003e' under\nthe TSDB's date directory.",
"operationId": "TSDBSnapshot",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/prometheusTSDBSnapshotResponse"
}
}
},
"tags": [
"Admin"
]
}
}
},
"definitions": {
"prometheusLabelMatcher": {
"type": "object",
"properties": {
"type": {
"$ref": "#/definitions/prometheusLabelMatcherType"
},
"name": {
"type": "string"
},
"value": {
"type": "string"
}
},
"description": "Matcher specifies a rule, which can match or set of labels or not."
},
"prometheusLabelMatcherType": {
"type": "string",
"enum": [
"EQ",
"NEQ",
"RE",
"NRE"
],
"default": "EQ"
},
"prometheusSeriesDeleteRequest": {
"type": "object",
"properties": {
"min_time": {
"type": "string",
"format": "date-time"
},
"max_time": {
"type": "string",
"format": "date-time"
},
"matchers": {
"type": "array",
"items": {
"$ref": "#/definitions/prometheusLabelMatcher"
}
}
}
},
"prometheusSeriesDeleteResponse": {
"type": "object"
},
"prometheusTSDBSnapshotRequest": {
"type": "object"
},
"prometheusTSDBSnapshotResponse": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
}
}
}
Loading

0 comments on commit ccf9e62

Please sign in to comment.