Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(analysis): add Apache SkyWalking as metrics provider #2491

Merged
merged 2 commits into from
Feb 16, 2023
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
35 changes: 35 additions & 0 deletions docs/analysis/skywalking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Apache SkyWalking Metrics

!!! important
Available since v1.5.0

A [SkyWalking](https://skywalking.apache.org/) query using GraphQL can be used to obtain measurements for analysis.

```yaml
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: apdex
spec:
args:
- name: service-name
metrics:
- name: apdex
interval: 5m
successCondition: "all(result.service_apdex.values.values, {asFloat(.value) >= 9900})"
failureLimit: 3
provider:
skywalking:
interval: 3m
address: http://skywalking-oap.istio-system:12800
query: |
query queryData($duration: Duration!) {
service_apdex: readMetricsValues(
condition: { name: "service_apdex", entity: { scope: Service, serviceName: "{{ args.service-name }}", normal: true } },
duration: $duration) {
label values { values { value } }
}
}
```

The `result` evaluated for the query depends on the specific GraphQL you give, you can try to run the GraphQL query first and inspect the output format, then compose the condition.
42 changes: 42 additions & 0 deletions docs/features/kustomize/rollout_cr_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4180,6 +4180,20 @@
},
"type": "object"
},
"skywalking": {
"properties": {
"address": {
"type": "string"
},
"interval": {
"type": "string"
},
"query": {
"type": "string"
}
},
"type": "object"
},
"wavefront": {
"properties": {
"address": {
Expand Down Expand Up @@ -8452,6 +8466,20 @@
},
"type": "object"
},
"skywalking": {
"properties": {
"address": {
"type": "string"
},
"interval": {
"type": "string"
},
"query": {
"type": "string"
}
},
"type": "object"
},
"wavefront": {
"properties": {
"address": {
Expand Down Expand Up @@ -12724,6 +12752,20 @@
},
"type": "object"
},
"skywalking": {
"properties": {
"address": {
"type": "string"
},
"interval": {
"type": "string"
},
"query": {
"type": "string"
}
},
"type": "object"
},
"wavefront": {
"properties": {
"address": {
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ require (

)

require github.com/matryer/is v1.4.0 // indirect

require (
cloud.google.com/go/compute v1.15.1 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
Expand Down Expand Up @@ -129,6 +131,7 @@ require (
github.com/json-iterator/go v1.1.12 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/lunixbochs/vtclean v1.0.0 // indirect
github.com/machinebox/graphql v0.2.2
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,8 @@ github.com/lunixbochs/vtclean v1.0.0 h1:xu2sLAri4lGiovBDQKxl5mrXyESr3gUr5m5SM5+L
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5/go.mod h1:c2mYKRyMb1BPkO5St0c/ps62L4S0W2NAkaTXj9qEI+0=
github.com/lusis/slack-test v0.0.0-20190426140909-c40012f20018/go.mod h1:sFlOUpQL1YcjhFVXhg1CG8ZASEs/Mf1oVb6H75JL/zg=
github.com/machinebox/graphql v0.2.2 h1:dWKpJligYKhYKO5A2gvNhkJdQMNZeChZYyBbrZkBZfo=
github.com/machinebox/graphql v0.2.2/go.mod h1:F+kbVMHuwrQ5tYgU9JXlnskM8nOaFxCAEolaQybkjWA=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
Expand All @@ -649,6 +651,8 @@ github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
github.com/matryer/moq v0.2.7/go.mod h1:kITsx543GOENm48TUAQyJ9+SAvFSr7iGQXPoth/VUBk=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
Expand Down
9 changes: 9 additions & 0 deletions manifests/crds/analysis-run-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2710,6 +2710,15 @@ spec:
query:
type: string
type: object
skywalking:
properties:
address:
type: string
interval:
type: string
query:
type: string
type: object
wavefront:
properties:
address:
Expand Down
9 changes: 9 additions & 0 deletions manifests/crds/analysis-template-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2706,6 +2706,15 @@ spec:
query:
type: string
type: object
skywalking:
properties:
address:
type: string
interval:
type: string
query:
type: string
type: object
wavefront:
properties:
address:
Expand Down
9 changes: 9 additions & 0 deletions manifests/crds/cluster-analysis-template-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2706,6 +2706,15 @@ spec:
query:
type: string
type: object
skywalking:
properties:
address:
type: string
interval:
type: string
query:
type: string
type: object
wavefront:
properties:
address:
Expand Down
27 changes: 27 additions & 0 deletions manifests/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2711,6 +2711,15 @@ spec:
query:
type: string
type: object
skywalking:
properties:
address:
type: string
interval:
type: string
query:
type: string
type: object
wavefront:
properties:
address:
Expand Down Expand Up @@ -5591,6 +5600,15 @@ spec:
query:
type: string
type: object
skywalking:
properties:
address:
type: string
interval:
type: string
query:
type: string
type: object
wavefront:
properties:
address:
Expand Down Expand Up @@ -8357,6 +8375,15 @@ spec:
query:
type: string
type: object
skywalking:
properties:
address:
type: string
interval:
type: string
query:
type: string
type: object
wavefront:
properties:
address:
Expand Down
11 changes: 10 additions & 1 deletion metricproviders/metricproviders.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"fmt"

"github.com/argoproj/argo-rollouts/metric"
"github.com/argoproj/argo-rollouts/metricproviders/influxdb"
"github.com/argoproj/argo-rollouts/metricproviders/skywalking"

"github.com/argoproj/argo-rollouts/metricproviders/cloudwatch"
"github.com/argoproj/argo-rollouts/metricproviders/datadog"
"github.com/argoproj/argo-rollouts/metricproviders/graphite"
"github.com/argoproj/argo-rollouts/metricproviders/influxdb"
"github.com/argoproj/argo-rollouts/metricproviders/kayenta"
"github.com/argoproj/argo-rollouts/metricproviders/newrelic"
"github.com/argoproj/argo-rollouts/metricproviders/plugin"
Expand Down Expand Up @@ -85,6 +86,12 @@ func (f *ProviderFactory) NewProvider(logCtx log.Entry, metric v1alpha1.Metric)
return nil, err
}
return influxdb.NewInfluxdbProvider(client, logCtx), nil
case skywalking.ProviderType:
client, err := skywalking.NewSkyWalkingClient(metric, f.KubeClient)
if err != nil {
return nil, err
}
return skywalking.NewSkyWalkingProvider(client, logCtx), nil
case plugin.ProviderType:
plugin, err := plugin.NewRpcPlugin(metric)
return plugin, err
Expand Down Expand Up @@ -114,6 +121,8 @@ func Type(metric v1alpha1.Metric) string {
return graphite.ProviderType
} else if metric.Provider.Influxdb != nil {
return influxdb.ProviderType
} else if metric.Provider.SkyWalking != nil {
return skywalking.ProviderType
} else if metric.Provider.Plugin != nil {
return plugin.ProviderType
}
Expand Down
13 changes: 13 additions & 0 deletions metricproviders/skywalking/mock_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package skywalking

type mockAPI struct {
err error
results interface{}
}

func (m mockAPI) Query(query string) (interface{}, error) {
if m.err != nil {
return m.results, m.err
}
return m.results, nil
}
Loading