Skip to content

Commit 75723b2

Browse files
feat(analysis): add Apache SkyWalking as metrics provider
Signed-off-by: kezhenxu94 <[email protected]> Signed-off-by: zachaller <[email protected]> Co-authored-by: zachaller <[email protected]>
1 parent 4afac4e commit 75723b2

21 files changed

+1403
-512
lines changed

docs/analysis/skywalking.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Apache SkyWalking Metrics
2+
3+
!!! important
4+
Available since v1.5.0
5+
6+
A [SkyWalking](https://skywalking.apache.org/) query using GraphQL can be used to obtain measurements for analysis.
7+
8+
```yaml
9+
apiVersion: argoproj.io/v1alpha1
10+
kind: AnalysisTemplate
11+
metadata:
12+
name: apdex
13+
spec:
14+
args:
15+
- name: service-name
16+
metrics:
17+
- name: apdex
18+
interval: 5m
19+
successCondition: "all(result.service_apdex.values.values, {asFloat(.value) >= 9900})"
20+
failureLimit: 3
21+
provider:
22+
skywalking:
23+
interval: 3m
24+
address: http://skywalking-oap.istio-system:12800
25+
query: |
26+
query queryData($duration: Duration!) {
27+
service_apdex: readMetricsValues(
28+
condition: { name: "service_apdex", entity: { scope: Service, serviceName: "{{ args.service-name }}", normal: true } },
29+
duration: $duration) {
30+
label values { values { value } }
31+
}
32+
}
33+
```
34+
35+
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.

docs/features/kustomize/rollout_cr_schema.json

+42
Original file line numberDiff line numberDiff line change
@@ -4180,6 +4180,20 @@
41804180
},
41814181
"type": "object"
41824182
},
4183+
"skywalking": {
4184+
"properties": {
4185+
"address": {
4186+
"type": "string"
4187+
},
4188+
"interval": {
4189+
"type": "string"
4190+
},
4191+
"query": {
4192+
"type": "string"
4193+
}
4194+
},
4195+
"type": "object"
4196+
},
41834197
"wavefront": {
41844198
"properties": {
41854199
"address": {
@@ -8452,6 +8466,20 @@
84528466
},
84538467
"type": "object"
84548468
},
8469+
"skywalking": {
8470+
"properties": {
8471+
"address": {
8472+
"type": "string"
8473+
},
8474+
"interval": {
8475+
"type": "string"
8476+
},
8477+
"query": {
8478+
"type": "string"
8479+
}
8480+
},
8481+
"type": "object"
8482+
},
84558483
"wavefront": {
84568484
"properties": {
84578485
"address": {
@@ -12724,6 +12752,20 @@
1272412752
},
1272512753
"type": "object"
1272612754
},
12755+
"skywalking": {
12756+
"properties": {
12757+
"address": {
12758+
"type": "string"
12759+
},
12760+
"interval": {
12761+
"type": "string"
12762+
},
12763+
"query": {
12764+
"type": "string"
12765+
}
12766+
},
12767+
"type": "object"
12768+
},
1272712769
"wavefront": {
1272812770
"properties": {
1272912771
"address": {

go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ require (
5555

5656
)
5757

58+
require github.com/matryer/is v1.4.0 // indirect
59+
5860
require (
5961
cloud.google.com/go/compute v1.15.1 // indirect
6062
cloud.google.com/go/compute/metadata v0.2.3 // indirect
@@ -129,6 +131,7 @@ require (
129131
github.com/json-iterator/go v1.1.12 // indirect
130132
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
131133
github.com/lunixbochs/vtclean v1.0.0 // indirect
134+
github.com/machinebox/graphql v0.2.2
132135
github.com/mailru/easyjson v0.7.7 // indirect
133136
github.com/mattn/go-colorable v0.1.12 // indirect
134137
github.com/mattn/go-isatty v0.0.14 // indirect

go.sum

+4
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,8 @@ github.com/lunixbochs/vtclean v1.0.0 h1:xu2sLAri4lGiovBDQKxl5mrXyESr3gUr5m5SM5+L
638638
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
639639
github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5/go.mod h1:c2mYKRyMb1BPkO5St0c/ps62L4S0W2NAkaTXj9qEI+0=
640640
github.com/lusis/slack-test v0.0.0-20190426140909-c40012f20018/go.mod h1:sFlOUpQL1YcjhFVXhg1CG8ZASEs/Mf1oVb6H75JL/zg=
641+
github.com/machinebox/graphql v0.2.2 h1:dWKpJligYKhYKO5A2gvNhkJdQMNZeChZYyBbrZkBZfo=
642+
github.com/machinebox/graphql v0.2.2/go.mod h1:F+kbVMHuwrQ5tYgU9JXlnskM8nOaFxCAEolaQybkjWA=
641643
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
642644
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
643645
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
@@ -649,6 +651,8 @@ github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7
649651
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
650652
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
651653
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
654+
github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
655+
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
652656
github.com/matryer/moq v0.2.7/go.mod h1:kITsx543GOENm48TUAQyJ9+SAvFSr7iGQXPoth/VUBk=
653657
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
654658
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=

manifests/crds/analysis-run-crd.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -2710,6 +2710,15 @@ spec:
27102710
query:
27112711
type: string
27122712
type: object
2713+
skywalking:
2714+
properties:
2715+
address:
2716+
type: string
2717+
interval:
2718+
type: string
2719+
query:
2720+
type: string
2721+
type: object
27132722
wavefront:
27142723
properties:
27152724
address:

manifests/crds/analysis-template-crd.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -2706,6 +2706,15 @@ spec:
27062706
query:
27072707
type: string
27082708
type: object
2709+
skywalking:
2710+
properties:
2711+
address:
2712+
type: string
2713+
interval:
2714+
type: string
2715+
query:
2716+
type: string
2717+
type: object
27092718
wavefront:
27102719
properties:
27112720
address:

manifests/crds/cluster-analysis-template-crd.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -2706,6 +2706,15 @@ spec:
27062706
query:
27072707
type: string
27082708
type: object
2709+
skywalking:
2710+
properties:
2711+
address:
2712+
type: string
2713+
interval:
2714+
type: string
2715+
query:
2716+
type: string
2717+
type: object
27092718
wavefront:
27102719
properties:
27112720
address:

manifests/install.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -2711,6 +2711,15 @@ spec:
27112711
query:
27122712
type: string
27132713
type: object
2714+
skywalking:
2715+
properties:
2716+
address:
2717+
type: string
2718+
interval:
2719+
type: string
2720+
query:
2721+
type: string
2722+
type: object
27142723
wavefront:
27152724
properties:
27162725
address:
@@ -5591,6 +5600,15 @@ spec:
55915600
query:
55925601
type: string
55935602
type: object
5603+
skywalking:
5604+
properties:
5605+
address:
5606+
type: string
5607+
interval:
5608+
type: string
5609+
query:
5610+
type: string
5611+
type: object
55945612
wavefront:
55955613
properties:
55965614
address:
@@ -8357,6 +8375,15 @@ spec:
83578375
query:
83588376
type: string
83598377
type: object
8378+
skywalking:
8379+
properties:
8380+
address:
8381+
type: string
8382+
interval:
8383+
type: string
8384+
query:
8385+
type: string
8386+
type: object
83608387
wavefront:
83618388
properties:
83628389
address:

metricproviders/metricproviders.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import (
44
"fmt"
55

66
"github.com/argoproj/argo-rollouts/metric"
7+
"github.com/argoproj/argo-rollouts/metricproviders/influxdb"
8+
"github.com/argoproj/argo-rollouts/metricproviders/skywalking"
79

810
"github.com/argoproj/argo-rollouts/metricproviders/cloudwatch"
911
"github.com/argoproj/argo-rollouts/metricproviders/datadog"
1012
"github.com/argoproj/argo-rollouts/metricproviders/graphite"
11-
"github.com/argoproj/argo-rollouts/metricproviders/influxdb"
1213
"github.com/argoproj/argo-rollouts/metricproviders/kayenta"
1314
"github.com/argoproj/argo-rollouts/metricproviders/newrelic"
1415
"github.com/argoproj/argo-rollouts/metricproviders/plugin"
@@ -85,6 +86,12 @@ func (f *ProviderFactory) NewProvider(logCtx log.Entry, metric v1alpha1.Metric)
8586
return nil, err
8687
}
8788
return influxdb.NewInfluxdbProvider(client, logCtx), nil
89+
case skywalking.ProviderType:
90+
client, err := skywalking.NewSkyWalkingClient(metric, f.KubeClient)
91+
if err != nil {
92+
return nil, err
93+
}
94+
return skywalking.NewSkyWalkingProvider(client, logCtx), nil
8895
case plugin.ProviderType:
8996
plugin, err := plugin.NewRpcPlugin(metric)
9097
return plugin, err
@@ -114,6 +121,8 @@ func Type(metric v1alpha1.Metric) string {
114121
return graphite.ProviderType
115122
} else if metric.Provider.Influxdb != nil {
116123
return influxdb.ProviderType
124+
} else if metric.Provider.SkyWalking != nil {
125+
return skywalking.ProviderType
117126
} else if metric.Provider.Plugin != nil {
118127
return plugin.ProviderType
119128
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package skywalking
2+
3+
type mockAPI struct {
4+
err error
5+
results interface{}
6+
}
7+
8+
func (m mockAPI) Query(query string) (interface{}, error) {
9+
if m.err != nil {
10+
return m.results, m.err
11+
}
12+
return m.results, nil
13+
}

0 commit comments

Comments
 (0)