1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-04-21 11:48:53 +00:00

Simplify ServiceMonitor to simply use StaticTargets

This commit is contained in:
Matthias Loibl 2018-04-05 20:25:39 +02:00
parent 1780729b5a
commit 83f233ae32
No known key found for this signature in database
GPG key ID: B1C7DF661ABB2C1A
6 changed files with 25 additions and 89 deletions
Documentation
example/prometheus-operator-crd
pkg

View file

@ -29,7 +29,6 @@ This Document documents the types introduced by the Prometheus Operator to be co
* [ServiceMonitor](#servicemonitor)
* [ServiceMonitorList](#servicemonitorlist)
* [ServiceMonitorSpec](#servicemonitorspec)
* [StaticConfig](#staticconfig)
* [StorageSpec](#storagespec)
* [TLSConfig](#tlsconfig)
@ -152,7 +151,7 @@ Endpoint defines a scrapeable endpoint serving Prometheus metrics.
| honorLabels | HonorLabels chooses the metric's labels on collisions with target labels. | bool | false |
| basicAuth | BasicAuth allow an endpoint to authenticate over basic authentication More info: https://prometheus.io/docs/operating/configuration/#endpoints | *[BasicAuth](#basicauth) | false |
| metricRelabelings | MetricRelabelConfigs to apply to samples before ingestion. | []*[RelabelConfig](#relabelconfig) | false |
| staticConfigs | StaticConfigs with targets to scrape. | *[StaticConfig](#staticconfig) | false |
| staticTargets | StaticTargets with targets to scrape. | []string | false |
[Back to TOC](#table-of-contents)
@ -328,16 +327,6 @@ ServiceMonitorSpec contains specification parameters for a ServiceMonitor.
[Back to TOC](#table-of-contents)
## StaticConfig
StaticConfig allows to specify a set of targets and parameters describing how to scrape them. More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#<static_config>
| Field | Description | Scheme | Required |
| ----- | ----------- | ------ | -------- |
| targets | | []string | true |
[Back to TOC](#table-of-contents)
## StorageSpec
StorageSpec defines the configured storage for a group Prometheus servers.

View file

@ -140,16 +140,11 @@ spec:
scrapeTimeout:
description: Timeout after which the scrape is ended
type: string
staticConfigs:
description: 'StaticConfig allows to specify a set of targets
and parameters describing how to scrape them. More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#<static_config>'
properties:
targets:
items:
type: string
type: array
required:
- targets
staticTargets:
description: StaticTargets with targets to scrape.
items:
type: string
type: array
targetPort: {}
tlsConfig:
description: TLSConfig specifies TLS configuration parameters.

View file

@ -532,17 +532,25 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
},
},
},
"staticConfigs": {
"staticTargets": {
SchemaProps: spec.SchemaProps{
Description: "StaticConfigs with targets to scrape.",
Ref: ref("github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.StaticConfig"),
Description: "StaticTargets with targets to scrape.",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
},
},
},
},
},
},
Dependencies: []string{
"github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.BasicAuth", "github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.RelabelConfig", "github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.StaticConfig", "github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.TLSConfig", "k8s.io/apimachinery/pkg/util/intstr.IntOrString"},
"github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.BasicAuth", "github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.RelabelConfig", "github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.TLSConfig", "k8s.io/apimachinery/pkg/util/intstr.IntOrString"},
},
"github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.NamespaceSelector": {
Schema: spec.Schema{
@ -1307,30 +1315,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
Dependencies: []string{
"github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.Endpoint", "github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.NamespaceSelector", "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"},
},
"github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.StaticConfig": {
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "StaticConfig allows to specify a set of targets and parameters describing how to scrape them. More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#<static_config>",
Properties: map[string]spec.Schema{
"targets": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
},
},
},
},
Required: []string{"targets"},
},
},
Dependencies: []string{},
},
"github.com/coreos/prometheus-operator/pkg/client/monitoring/v1.StorageSpec": {
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{

View file

@ -332,15 +332,8 @@ type Endpoint struct {
BasicAuth *BasicAuth `json:"basicAuth,omitempty"`
// MetricRelabelConfigs to apply to samples before ingestion.
MetricRelabelConfigs []*RelabelConfig `json:"metricRelabelings,omitempty"`
// StaticConfigs with targets to scrape.
StaticConfigs *StaticConfig `json:"staticConfigs,omitempty"`
}
// StaticConfig allows to specify a set of targets and parameters describing how to scrape them.
// More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#<static_config>
// +k8s:openapi-gen=true
type StaticConfig struct {
Targets []string `json:"targets"`
// StaticTargets with targets to scrape.
StaticTargets []string `json:"staticTargets,omitempty"`
}
// BasicAuth allow an endpoint to authenticate over basic authentication

View file

@ -333,14 +333,10 @@ func (in *Endpoint) DeepCopyInto(out *Endpoint) {
}
}
}
if in.StaticConfigs != nil {
in, out := &in.StaticConfigs, &out.StaticConfigs
if *in == nil {
*out = nil
} else {
*out = new(StaticConfig)
(*in).DeepCopyInto(*out)
}
if in.StaticTargets != nil {
in, out := &in.StaticTargets, &out.StaticTargets
*out = make([]string, len(*in))
copy(*out, *in)
}
return
}
@ -773,27 +769,6 @@ func (in *ServiceMonitorSpec) DeepCopy() *ServiceMonitorSpec {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *StaticConfig) DeepCopyInto(out *StaticConfig) {
*out = *in
if in.Targets != nil {
in, out := &in.Targets, &out.Targets
*out = make([]string, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StaticConfig.
func (in *StaticConfig) DeepCopy() *StaticConfig {
if in == nil {
return nil
}
out := new(StaticConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *StorageSpec) DeepCopyInto(out *StorageSpec) {
*out = *in

View file

@ -332,7 +332,7 @@ func makeServiceMonitors() map[string]*monitoringv1.ServiceMonitor {
Interval: "30s",
Path: "/federate",
Params: map[string][]string{"metrics[]": {"{__name__=~\"job:.*\"}"}},
StaticConfigs: &monitoringv1.StaticConfig{
StaticTargets: &monitoringv1.StaticConfig{
Targets: []string{
"source-prometheus-1:9090",
"source-prometheus-2:9090",