Skip to content

Commit

Permalink
feat: add support for influxdb as a metrics provider (#1839)
Browse files Browse the repository at this point in the history
* feat: add InfluxDB metric provider implementation

Signed-off-by: Jayme Bird <[email protected]>

* feat: add influx to metric provider util count, add missing graphite

Signed-off-by: Jayme Bird <[email protected]>

* feat: add protobuf definitions for InfluxdbMetric

Signed-off-by: Jayme Bird <[email protected]>

* feat: add docs for the Influxdb metrics provider

Signed-off-by: Jayme Bird <[email protected]>

* feat: add tests for influxdb metrics provider

Signed-off-by: Jayme Bird <[email protected]>

* feat: add go mod replace for version of moq due to security issue

Signed-off-by: Jayme Bird <[email protected]>

* feat: update error message to distinguish failed cases - review feedback

Signed-off-by: Jayme Bird <[email protected]>

* feat: update tests to simplify mocking of QueryTableResult

An upstream change to the influx go client makes it easier to mock
QueryTableResult in tests. This removes a lot of boilerplate duplication
in the tests.

Signed-off-by: Jayme Bird <[email protected]>

* feat: re-run codegen

Signed-off-by: Jayme Bird <[email protected]>
  • Loading branch information
jaymebrd authored Jun 23, 2022
1 parent 5c32e84 commit e3c33d8
Show file tree
Hide file tree
Showing 22 changed files with 1,475 additions and 526 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ For these reasons, in large scale high-volume production environments, a rolling
* Customizable metric queries and analysis of business KPIs
* Ingress controller integration: NGINX, ALB
* Service Mesh integration: Istio, Linkerd, SMI
* Metric provider integration: Prometheus, Wavefront, Kayenta, Web, Kubernetes Jobs, Datadog, New Relic
* Metric provider integration: Prometheus, Wavefront, Kayenta, Web, Kubernetes Jobs, Datadog, New Relic, InfluxDB

## Documentation
To learn more about Argo Rollouts go to the [complete documentation](https://argoproj.github.io/argo-rollouts/).
Expand Down
41 changes: 41 additions & 0 deletions docs/analysis/influxdb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# InfluxDB Metrics

An [InfluxDB](https://www.influxdata.com/) query using [Flux](https://docs.influxdata.com/influxdb/cloud/query-data/get-started/query-influxdb/) can be used to obtain measurements for analysis.

```yaml
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: error-rate
spec:
args:
- name: application-name
metrics:
- name: error-rate
# NOTE: To be consistent with the prometheus metrics provider InfluxDB query results are returned as an array.
# In the example we're looking at index 0 of the returned array to obtain the value we're using for the success condition
successCondition: result[0] <= 0.01
provider:
influxdb:
profile: my-influxdb-secret # optional, defaults to 'influxdb'
query: |
from(bucket: "app_istio")
|> range(start: -15m)
|> filter(fn: (r) => r["destination_workload"] == "{{ args.application-name }}")
|> filter(fn: (r) => r["_measurement"] == "istio:istio_requests_errors_percentage:rate1m:5xx")
```
An InfluxDB access profile can be configured using a Kubernetes secret in the `argo-rollouts` namespace. Alternate accounts can be used by creating more secrets of the same format and specifying which secret to use in the metric provider configuration using the `profile` field.

```yaml
apiVersion: v1
kind: Secret
metadata:
name: influxdb
type: Opaque
data:
address: <infuxdb-url>
authToken: <influxdb-auth-token>
org: <influxdb-org>
```
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ For these reasons, in large scale high-volume production environments, a rolling
* Ingress controller integration: NGINX, ALB
* Service Mesh integration: Istio, Linkerd, SMI
* Simultaneous usage of multiple providers: SMI + NGINX, Istio + ALB, etc.
* Metric provider integration: Prometheus, Wavefront, Kayenta, Web, Kubernetes Jobs, Datadog, New Relic, Graphite
* Metric provider integration: Prometheus, Wavefront, Kayenta, Web, Kubernetes Jobs, Datadog, New Relic, Graphite, InfluxDB

## Quick Start

Expand Down
9 changes: 7 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require (
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.2
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/influxdata/influxdb-client-go/v2 v2.8.1
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a
github.com/mitchellh/mapstructure v1.4.3
github.com/newrelic/newrelic-client-go v0.72.0
Expand Down Expand Up @@ -82,6 +83,7 @@ require (
github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5 // indirect
github.com/cyphar/filepath-securejoin v0.2.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deepmap/oapi-codegen v1.9.1 // indirect
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
Expand Down Expand Up @@ -113,6 +115,7 @@ require (
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/influxdata/line-protocol v0.0.0-20210922203350-b1ad95c89adf // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand Down Expand Up @@ -145,9 +148,9 @@ require (
github.com/whilp/git-urls v0.0.0-20191001220047-6db9661140c0 // indirect
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/mod v0.5.1 // indirect
golang.org/x/net v0.0.0-20220121210141-e204ce36a2ba // indirect
golang.org/x/net v0.0.0-20220407224826-aac1ed45d8e3 // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
Expand Down Expand Up @@ -204,3 +207,5 @@ replace (
k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.23.1
k8s.io/sample-controller => k8s.io/sample-controller v0.23.1
)

replace github.com/matryer/moq => github.com/matryer/moq v0.1.6
Loading

0 comments on commit e3c33d8

Please sign in to comment.