Skip to content

Commit e37fea1

Browse files
committed
Add SkyWalking metrics provider
Signed-off-by: kezhenxu94 <[email protected]>
1 parent 2555e2c commit e37fea1

22 files changed

+1422
-503
lines changed

docs/analysis/skywalking.md

Lines changed: 35 additions & 0 deletions
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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4176,6 +4176,20 @@
41764176
},
41774177
"type": "object"
41784178
},
4179+
"skywalking": {
4180+
"properties": {
4181+
"address": {
4182+
"type": "string"
4183+
},
4184+
"interval": {
4185+
"type": "string"
4186+
},
4187+
"query": {
4188+
"type": "string"
4189+
}
4190+
},
4191+
"type": "object"
4192+
},
41794193
"wavefront": {
41804194
"properties": {
41814195
"address": {
@@ -8444,6 +8458,20 @@
84448458
},
84458459
"type": "object"
84468460
},
8461+
"skywalking": {
8462+
"properties": {
8463+
"address": {
8464+
"type": "string"
8465+
},
8466+
"interval": {
8467+
"type": "string"
8468+
},
8469+
"query": {
8470+
"type": "string"
8471+
}
8472+
},
8473+
"type": "object"
8474+
},
84478475
"wavefront": {
84488476
"properties": {
84498477
"address": {
@@ -12712,6 +12740,20 @@
1271212740
},
1271312741
"type": "object"
1271412742
},
12743+
"skywalking": {
12744+
"properties": {
12745+
"address": {
12746+
"type": "string"
12747+
},
12748+
"interval": {
12749+
"type": "string"
12750+
},
12751+
"query": {
12752+
"type": "string"
12753+
}
12754+
},
12755+
"type": "object"
12756+
},
1271512757
"wavefront": {
1271612758
"properties": {
1271712759
"address": {

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ require (
5353

5454
)
5555

56+
require github.com/matryer/is v1.4.0 // indirect
57+
5658
require (
5759
cloud.google.com/go/compute v1.7.0 // indirect
5860
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
@@ -121,6 +123,7 @@ require (
121123
github.com/json-iterator/go v1.1.12 // indirect
122124
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
123125
github.com/lunixbochs/vtclean v1.0.0 // indirect
126+
github.com/machinebox/graphql v0.2.2
124127
github.com/mailru/easyjson v0.7.7 // indirect
125128
github.com/mattn/go-colorable v0.1.12 // indirect
126129
github.com/mattn/go-isatty v0.0.14 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,8 @@ github.com/lunixbochs/vtclean v1.0.0 h1:xu2sLAri4lGiovBDQKxl5mrXyESr3gUr5m5SM5+L
667667
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
668668
github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5/go.mod h1:c2mYKRyMb1BPkO5St0c/ps62L4S0W2NAkaTXj9qEI+0=
669669
github.com/lusis/slack-test v0.0.0-20190426140909-c40012f20018/go.mod h1:sFlOUpQL1YcjhFVXhg1CG8ZASEs/Mf1oVb6H75JL/zg=
670+
github.com/machinebox/graphql v0.2.2 h1:dWKpJligYKhYKO5A2gvNhkJdQMNZeChZYyBbrZkBZfo=
671+
github.com/machinebox/graphql v0.2.2/go.mod h1:F+kbVMHuwrQ5tYgU9JXlnskM8nOaFxCAEolaQybkjWA=
670672
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
671673
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
672674
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
@@ -678,6 +680,8 @@ github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7
678680
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
679681
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
680682
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
683+
github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
684+
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
681685
github.com/matryer/moq v0.2.7/go.mod h1:kITsx543GOENm48TUAQyJ9+SAvFSr7iGQXPoth/VUBk=
682686
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
683687
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=

manifests/crds/analysis-run-crd.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2707,6 +2707,15 @@ spec:
27072707
query:
27082708
type: string
27092709
type: object
2710+
skywalking:
2711+
properties:
2712+
address:
2713+
type: string
2714+
interval:
2715+
type: string
2716+
query:
2717+
type: string
2718+
type: object
27102719
wavefront:
27112720
properties:
27122721
address:

manifests/crds/analysis-template-crd.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,6 +2703,15 @@ spec:
27032703
query:
27042704
type: string
27052705
type: object
2706+
skywalking:
2707+
properties:
2708+
address:
2709+
type: string
2710+
interval:
2711+
type: string
2712+
query:
2713+
type: string
2714+
type: object
27062715
wavefront:
27072716
properties:
27082717
address:

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,6 +2703,15 @@ spec:
27032703
query:
27042704
type: string
27052705
type: object
2706+
skywalking:
2707+
properties:
2708+
address:
2709+
type: string
2710+
interval:
2711+
type: string
2712+
query:
2713+
type: string
2714+
type: object
27062715
wavefront:
27072716
properties:
27082717
address:

manifests/install.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,6 +2708,15 @@ spec:
27082708
query:
27092709
type: string
27102710
type: object
2711+
skywalking:
2712+
properties:
2713+
address:
2714+
type: string
2715+
interval:
2716+
type: string
2717+
query:
2718+
type: string
2719+
type: object
27112720
wavefront:
27122721
properties:
27132722
address:
@@ -5585,6 +5594,15 @@ spec:
55855594
query:
55865595
type: string
55875596
type: object
5597+
skywalking:
5598+
properties:
5599+
address:
5600+
type: string
5601+
interval:
5602+
type: string
5603+
query:
5604+
type: string
5605+
type: object
55885606
wavefront:
55895607
properties:
55905608
address:
@@ -8348,6 +8366,15 @@ spec:
83488366
query:
83498367
type: string
83508368
type: object
8369+
skywalking:
8370+
properties:
8371+
address:
8372+
type: string
8373+
interval:
8374+
type: string
8375+
query:
8376+
type: string
8377+
type: object
83518378
wavefront:
83528379
properties:
83538380
address:

manifests/namespace-install.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,6 +2708,15 @@ spec:
27082708
query:
27092709
type: string
27102710
type: object
2711+
skywalking:
2712+
properties:
2713+
address:
2714+
type: string
2715+
interval:
2716+
type: string
2717+
query:
2718+
type: string
2719+
type: object
27112720
wavefront:
27122721
properties:
27132722
address:
@@ -5585,6 +5594,15 @@ spec:
55855594
query:
55865595
type: string
55875596
type: object
5597+
skywalking:
5598+
properties:
5599+
address:
5600+
type: string
5601+
interval:
5602+
type: string
5603+
query:
5604+
type: string
5605+
type: object
55885606
wavefront:
55895607
properties:
55905608
address:
@@ -8348,6 +8366,15 @@ spec:
83488366
query:
83498367
type: string
83508368
type: object
8369+
skywalking:
8370+
properties:
8371+
address:
8372+
type: string
8373+
interval:
8374+
type: string
8375+
query:
8376+
type: string
8377+
type: object
83518378
wavefront:
83528379
properties:
83538380
address:

metricproviders/metricproviders.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55

66
"github.com/argoproj/argo-rollouts/metricproviders/influxdb"
7+
"github.com/argoproj/argo-rollouts/metricproviders/skywalking"
78

89
"github.com/argoproj/argo-rollouts/metricproviders/cloudwatch"
910
"github.com/argoproj/argo-rollouts/metricproviders/datadog"
@@ -101,6 +102,12 @@ func (f *ProviderFactory) NewProvider(logCtx log.Entry, metric v1alpha1.Metric)
101102
return nil, err
102103
}
103104
return influxdb.NewInfluxdbProvider(client, logCtx), nil
105+
case skywalking.ProviderType:
106+
client, err := skywalking.NewSkyWalkingClient(metric, f.KubeClient)
107+
if err != nil {
108+
return nil, err
109+
}
110+
return skywalking.NewSkyWalkingProvider(client, logCtx), nil
104111
default:
105112
return nil, fmt.Errorf("no valid provider in metric '%s'", metric.Name)
106113
}
@@ -127,6 +134,8 @@ func Type(metric v1alpha1.Metric) string {
127134
return graphite.ProviderType
128135
} else if metric.Provider.Influxdb != nil {
129136
return influxdb.ProviderType
137+
} else if metric.Provider.SkyWalking != nil {
138+
return skywalking.ProviderType
130139
}
131140

132141
return "Unknown Provider"

0 commit comments

Comments
 (0)