Skip to content

Commit

Permalink
Add SkyWalking metrics provider
Browse files Browse the repository at this point in the history
  • Loading branch information
kezhenxu94 committed Dec 19, 2022
1 parent 91e491c commit d441778
Show file tree
Hide file tree
Showing 19 changed files with 1,345 additions and 497 deletions.
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.3.3

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 @@ -4176,6 +4176,20 @@
},
"type": "object"
},
"skywalking": {
"properties": {
"address": {
"type": "string"
},
"interval": {
"type": "string"
},
"query": {
"type": "string"
}
},
"type": "object"
},
"wavefront": {
"properties": {
"address": {
Expand Down Expand Up @@ -8444,6 +8458,20 @@
},
"type": "object"
},
"skywalking": {
"properties": {
"address": {
"type": "string"
},
"interval": {
"type": "string"
},
"query": {
"type": "string"
}
},
"type": "object"
},
"wavefront": {
"properties": {
"address": {
Expand Down Expand Up @@ -12712,6 +12740,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 @@ -53,6 +53,8 @@ require (

)

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

require (
cloud.google.com/go/compute v1.7.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
Expand Down Expand Up @@ -121,6 +123,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 @@ -667,6 +667,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 @@ -678,6 +680,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 @@ -2707,6 +2707,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 @@ -2703,6 +2703,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 @@ -2703,6 +2703,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
21 changes: 21 additions & 0 deletions manifests/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2708,6 +2708,13 @@ spec:
query:
type: string
type: object
skywalking:
properties:
address:
type: string
query:
type: string
type: object
wavefront:
properties:
address:
Expand Down Expand Up @@ -5585,6 +5592,13 @@ spec:
query:
type: string
type: object
skywalking:
properties:
address:
type: string
query:
type: string
type: object
wavefront:
properties:
address:
Expand Down Expand Up @@ -8348,6 +8362,13 @@ spec:
query:
type: string
type: object
skywalking:
properties:
address:
type: string
query:
type: string
type: object
wavefront:
properties:
address:
Expand Down
21 changes: 21 additions & 0 deletions manifests/namespace-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2708,6 +2708,13 @@ spec:
query:
type: string
type: object
skywalking:
properties:
address:
type: string
query:
type: string
type: object
wavefront:
properties:
address:
Expand Down Expand Up @@ -5585,6 +5592,13 @@ spec:
query:
type: string
type: object
skywalking:
properties:
address:
type: string
query:
type: string
type: object
wavefront:
properties:
address:
Expand Down Expand Up @@ -8348,6 +8362,13 @@ spec:
query:
type: string
type: object
skywalking:
properties:
address:
type: string
query:
type: string
type: object
wavefront:
properties:
address:
Expand Down
9 changes: 9 additions & 0 deletions metricproviders/metricproviders.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"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"
Expand Down Expand Up @@ -101,6 +102,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
default:
return nil, fmt.Errorf("no valid provider in metric '%s'", metric.Name)
}
Expand All @@ -127,6 +134,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
}

return "Unknown Provider"
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

0 comments on commit d441778

Please sign in to comment.