Skip to content

Commit

Permalink
Merge branch 'master' into mod
Browse files Browse the repository at this point in the history
Signed-off-by: Goutham Veeramachaneni <gouthamve@gmail.com>
  • Loading branch information
gouthamve committed May 6, 2019
2 parents b92b0b1 + c4180aa commit 88db4e8
Show file tree
Hide file tree
Showing 534 changed files with 46,094 additions and 27,880 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:

integration:
docker:
- image: cortexproject/build-image:switch-imports-f7f4e51d7
- image: cortexproject/build-image:master-b645241c
- image: circleci/postgres:9.6.2-alpine
environment:
POSTGRES_DB: configs_test
Expand Down
35 changes: 22 additions & 13 deletions Gopkg.lock

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

114 changes: 114 additions & 0 deletions docs/configs-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Configs API

The configs service provides an API-driven multi-tenant approach to handling various configuration files for prometheus. The service hosts an API where users can read and write Prometheus rule files, Alertmanager configuration files, and Alertmanager templates to a database.

Each tenant will have it's own set of rule files, Alertmanager config, and templates. A POST operation will effectively replace the existing copy with the configs provided in the request body.

## Configs Format

At the current time of writing, the API is part-way through a migration from a single Configs service that handled all three sets of data to a split API ([Tracking issue](https://github.com/cortexproject/cortex/issues/619)). All APIs take and return all sets of data.

The following schema is used both when retrieving the current configs from the API and when setting new configs via the API.

### Schema:

```json
{
"id": 99,
"rule_format_version": "2",
"config": {
"alertmanager_config": "<standard alertmanager.yaml config>",
"rules_files": {
"rules.yaml": "<standard rules.yaml config>",
"rules2.yaml": "<standard rules.yaml config>"
},
"template_files": {
"templates.tmpl": "<standard template file>",
"templates2.tmpl": "<standard template file>"
}
}
}
```

### Formatting

`id` - should be incremented every time data is updated; Cortex will use the config with the highest number.

`rule_format_version` - allows compatibility for tenants with config in Prometheus V1 format. Pass "1" or "2" according to which Prometheus version you want to match.

`config.alertmanager_config` - The contents of the alertmanager config file should be as described [here](https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/), encoded as a single string to fit within the overall JSON payload.

`config.rules_files` - The contents of a rules file should be as described [here](http://prometheus.io/docs/prometheus/latest/configuration/recording_rules/), encoded as a single string to fit within the overall JSON payload.

`config.template_files` - The contents of a template file should be as described [here](https://prometheus.io/docs/alerting/notification_examples/#defining-reusable-templates), encoded as a single string to fit within the overall JSON payload.

## Endpoints

### Manage Alertmanager

`GET /api/prom/configs/alertmanager` - Get current Alertmanager config

- Normal Response Codes: OK(200)
- Error Response Codes: Unauthorized(401), NotFound(404)

`POST /api/prom/configs/alertmanager` - Replace current Alertmanager config

- Normal Response Codes: NoContent(204)
- Error Response Codes: Unauthorized(401), BadRequest(400)

`POST /api/prom/configs/alertmanager/validate` - Validate Alertmanager config

Normal Response: OK(200)
```json
{
"status": "success"
}
```

Error Response: BadRequest(400)
```json
{
"status": "error",
"error": "error message"
}
```

### Manage Rules

`GET /api/prom/configs/rules` - Get current rule files

- Normal Response Codes: OK(200)
- Error Response Codes: Unauthorized(400), NotFound(404)

`POST /api/prom/configs/rules` - Replace current rule files

- Normal Response Codes: NoContent(204)
- Error Response Codes: Unauthorized(401), BadRequest(400)

### Manage Templates

`GET /api/prom/configs/templates` - Get current templates

- Normal Response Codes: OK(200)
- Error Response Codes: Unauthorized(401), NotFound(404)

`POST /api/prom/configs/templates` - Replace current templates

- Normal Response Codes: NoContent(204)
- Error Response Codes: Unauthorized(401), BadRequest(400)

### Deactivate/Restore Configs

`DELETE /api/prom/configs/deactivate` - Disable configs for a tenant

- Normal Response Codes: OK(200)
- Error Response Codes: Unauthorized(401), NotFound(404)

`POST /api/prom/configs/restore` - Re-enable configs for a tenant

- Normal Response Codes OK(200)
- Error Response Codes: Unauthorized(401), NotFound(404)

These API endpoints will disable/enable the current Rule and Alertmanager configuration for a tenant.

Note that setting a new config will effectively "re-enable" the Rules and Alertmanager configuration for a tenant.
45 changes: 19 additions & 26 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,68 +23,61 @@ require (
github.com/go-kit/kit v0.8.0
github.com/gocql/gocql v0.0.0-20180113133114-697e7c57f99b
github.com/gogo/googleapis v1.1.0 // indirect
github.com/gogo/protobuf v1.2.0
github.com/gogo/protobuf v1.2.1
github.com/gogo/status v1.0.3
github.com/golang/protobuf v1.2.0
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db
github.com/golang/protobuf v1.3.1
github.com/golang/snappy v0.0.1
github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367 // indirect
github.com/googleapis/gnostic v0.2.0 // indirect
github.com/gophercloud/gophercloud v0.0.0-20190307220656-fe1ba5ce12dd // indirect
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f // indirect
github.com/gorilla/mux v1.6.2
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0
github.com/grpc-ecosystem/grpc-gateway v1.8.3 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/hashicorp/consul v1.1.0
github.com/hashicorp/go-cleanhttp v0.0.0-20170211013415-3573b8b52aa7
github.com/hashicorp/serf v0.8.1 // indirect
github.com/hashicorp/consul v1.4.4
github.com/hashicorp/go-cleanhttp v0.5.1
github.com/jonboulle/clockwork v0.1.0
github.com/json-iterator/go v1.1.5
github.com/julienschmidt/httprouter v1.1.0 // indirect
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 // indirect
github.com/lann/builder v0.0.0-20150808151131-f22ce00fd939 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/lib/pq v1.0.0
github.com/mattes/migrate v1.3.1
github.com/mattn/go-colorable v0.0.7 // indirect
github.com/mattn/go-isatty v0.0.2 // indirect
github.com/mattn/go-sqlite3 v1.10.0 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
github.com/oklog/oklog v0.2.2 // indirect
github.com/onsi/ginkgo v1.8.0 // indirect
github.com/onsi/gomega v1.5.0 // indirect
github.com/opentracing-contrib/go-grpc v0.0.0-20180928155321-4b5a12d3ff02
github.com/opentracing-contrib/go-stdlib v0.0.0-20170113013457-1de4cc2120e7
github.com/opentracing/opentracing-go v1.0.2
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/philhofer/fwd v0.0.0-20160129035939-98c11a7a6ec8 // indirect
github.com/pkg/errors v0.8.0
github.com/pkg/errors v0.8.1
github.com/prometheus/alertmanager v0.13.0
github.com/prometheus/client_golang v0.9.1
github.com/prometheus/common v0.0.0-20181119215939-b36ad289a3ea
github.com/prometheus/prometheus v0.0.0-20190312040920-59369491cfdf
github.com/prometheus/tsdb v0.6.1
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829
github.com/prometheus/common v0.3.0
github.com/prometheus/prometheus v0.0.0-20190417125241-3cc5f9d88062
github.com/prometheus/tsdb v0.7.2-0.20190506134726-2ae028114c89
github.com/segmentio/fasthash v0.0.0-20180216231524-a72b379d632e
github.com/sercand/kuberesolver v1.0.0 // indirect
github.com/sirupsen/logrus v1.0.6 // indirect
github.com/sercand/kuberesolver v2.1.0+incompatible // indirect
github.com/stretchr/testify v1.3.0
github.com/tinylib/msgp v0.0.0-20161221055906-38a6f61a768d // indirect
github.com/uber-go/atomic v1.3.2 // indirect
github.com/uber/jaeger-client-go v2.14.0+incompatible
github.com/uber/jaeger-lib v1.5.0 // indirect
github.com/weaveworks/billing-client v0.0.0-20171006123215-be0d55e547b1
github.com/weaveworks/common v0.0.0-20181109173936-c1808abf9c46
github.com/weaveworks/common v0.0.0-20190410110702-87611edc252e
github.com/weaveworks/mesh v0.0.0-20170131170447-5015f896ab62
github.com/weaveworks/promrus v1.2.0 // indirect
go.etcd.io/bbolt v1.3.2 // indirect
go.uber.org/atomic v1.3.2 // indirect
golang.org/x/net v0.0.0-20181220203305-927f97764cc3
golang.org/x/sys v0.0.0-20190209173611-3b5209105503
golang.org/x/net v0.0.0-20190311183353-d8887717615a
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b
google.golang.org/api v0.1.0
google.golang.org/grpc v1.19.0
gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138
google.golang.org/api v0.4.0
google.golang.org/grpc v1.19.1
gopkg.in/fsnotify/fsnotify.v1 v1.4.7 // indirect
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
gopkg.in/yaml.v2 v2.2.2
k8s.io/klog v0.2.0 // indirect
)
Loading

0 comments on commit 88db4e8

Please sign in to comment.