Skip to content

Commit

Permalink
Merge pull request #419 from weaveworks/metric-template
Browse files Browse the repository at this point in the history
Implement metric templates for Prometheus
  • Loading branch information
stefanprodan authored Feb 7, 2020
2 parents 1cca5a4 + eec287a commit ea39041
Show file tree
Hide file tree
Showing 69 changed files with 2,845 additions and 883 deletions.
2 changes: 2 additions & 0 deletions artifacts/flagger/account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ rules:
resources:
- canaries
- canaries/status
- metrictemplates
- metrictemplates/status
verbs: ["*"]
- apiGroups:
- networking.istio.io
Expand Down
76 changes: 73 additions & 3 deletions artifacts/flagger/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,29 @@ spec:
required: ["name", "threshold"]
properties:
name:
description: Name of the Prometheus metric
description: Name of the metric
type: string
interval:
description: Interval of the promql query
description: Interval of the query
type: string
pattern: "^[0-9]+(m|s)"
threshold:
description: Max scalar value accepted for this metric
description: Max value accepted for this metric
type: number
query:
description: Prometheus query
type: string
templateRef:
description: Metric template reference
type: object
required: ["name"]
properties:
name:
description: Name of this metric template
type: string
namespace:
description: Namespace of this metric template
type: string
webhooks:
description: Webhook list for this canary
type: array
Expand Down Expand Up @@ -322,3 +333,62 @@ spec:
type:
description: Type of this condition
type: string
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: metrictemplates.flagger.app
annotations:
helm.sh/resource-policy: keep
spec:
group: flagger.app
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
names:
plural: metrictemplates
singular: metrictemplate
kind: MetricTemplate
categories:
- all
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
properties:
spec:
required:
- provider
- query
properties:
provider:
description: Provider of this metric template
type: object
required:
- type
- address
properties:
type:
description: Type of this provider
type: string
enum:
- prometheus
- influxdb
address:
description: API address of this provider
type: string
secretRef:
description: Kubernetes secret reference containing the provider credentials
type: object
required:
- name
properties:
name:
description: Name of the Kubernetes secret
type: string
query:
description: Query of this metric template
type: string
88 changes: 79 additions & 9 deletions charts/flagger/templates/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ spec:
targetRef:
description: Deployment selector
type: object
required: ['apiVersion', 'kind', 'name']
required: ["apiVersion", "kind", "name"]
properties:
apiVersion:
type: string
Expand All @@ -91,7 +91,7 @@ spec:
anyOf:
- type: string
- type: object
required: ['apiVersion', 'kind', 'name']
required: ["apiVersion", "kind", "name"]
properties:
apiVersion:
type: string
Expand All @@ -104,7 +104,7 @@ spec:
anyOf:
- type: string
- type: object
required: ['apiVersion', 'kind', 'name']
required: ["apiVersion", "kind", "name"]
properties:
apiVersion:
type: string
Expand All @@ -114,7 +114,7 @@ spec:
type: string
service:
type: object
required: ['port']
required: ["port"]
properties:
name:
description: Kubernetes service name
Expand Down Expand Up @@ -213,21 +213,32 @@ spec:
properties:
items:
type: object
required: ['name', 'threshold']
required: ["name", "threshold"]
properties:
name:
description: Name of the Prometheus metric
description: Name of the metric
type: string
interval:
description: Interval of the promql query
description: Interval of the query
type: string
pattern: "^[0-9]+(m|s)"
threshold:
description: Max scalar value accepted for this metric
description: Max value accepted for this metric
type: number
query:
description: Prometheus query
type: string
templateRef:
description: Metric template reference
type: object
required: ["name"]
properties:
name:
description: Name of this metric template
type: string
namespace:
description: Namespace of this metric template
type: string
webhooks:
description: Webhook list for this canary
type: array
Expand Down Expand Up @@ -301,7 +312,7 @@ spec:
properties:
items:
type: object
required: ['type', 'status', 'reason']
required: ["type", "status", "reason"]
properties:
lastTransitionTime:
description: LastTransitionTime of this condition
Expand All @@ -323,4 +334,63 @@ spec:
type:
description: Type of this condition
type: string
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: metrictemplates.flagger.app
annotations:
helm.sh/resource-policy: keep
spec:
group: flagger.app
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
names:
plural: metrictemplates
singular: metrictemplate
kind: MetricTemplate
categories:
- all
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
properties:
spec:
required:
- provider
- query
properties:
provider:
description: Provider of this metric template
type: object
required:
- type
- address
properties:
type:
description: Type of this provider
type: string
enum:
- prometheus
- influxdb
address:
description: API address of this provider
type: string
secretRef:
description: Kubernetes secret reference containing the provider credentials
type: object
required:
- name
properties:
name:
description: Name of the Kubernetes secret
type: string
query:
description: Query of this metric template
type: string
{{- end }}
2 changes: 2 additions & 0 deletions charts/flagger/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ rules:
resources:
- canaries
- canaries/status
- metrictemplates
- metrictemplates/status
verbs: ["*"]
- apiGroups:
- networking.istio.io
Expand Down
Loading

0 comments on commit ea39041

Please sign in to comment.