Skip to content

Commit

Permalink
Remove direct dependency to Prometheus (#30)
Browse files Browse the repository at this point in the history
* chore(config,watcher): get rid of any dependency to prometheus

* feat(vendoring): no direct dependency to prometheus

* fix(examples): run the exmaples on the latest prometheus
  • Loading branch information
jlevesy authored May 24, 2023
1 parent 999c57d commit 498c417
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 803 deletions.
8 changes: 3 additions & 5 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import (
"errors"
"os"

promconfig "github.com/prometheus/prometheus/config"
_ "github.com/prometheus/prometheus/plugins"
"gopkg.in/yaml.v2"
)

type config struct {
Follower *promconfig.Config `yaml:"follower"`
Leader *promconfig.Config `yaml:"leader"`
Follower map[string]any `yaml:"follower"`
Leader map[string]any `yaml:"leader"`
}

func loadConfiguration(path string) (*config, error) {
Expand All @@ -33,7 +31,7 @@ func loadConfiguration(path string) (*config, error) {
return &cfg, nil
}

func writeConfiguration(path string, cfg *promconfig.Config) error {
func writeConfiguration(path string, cfg map[string]any) error {
b, err := yaml.Marshal(cfg)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion config/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (r *Reconciler) Reconcile(ctx context.Context) error {

if cfg.Leader != nil && r.leaderChecker != nil && r.leaderChecker.IsLeader() {
if err := mergo.Merge(
targetCfg,
&targetCfg,
cfg.Leader,
mergo.WithOverride,
mergo.WithAppendSlice,
Expand Down
27 changes: 3 additions & 24 deletions config/testdata/config_no_leader_result.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,13 @@
global:
scrape_interval: 1m
scrape_timeout: 10s
evaluation_interval: 1m
scrape_configs:
- job_name: foobar
honor_timestamps: true
scrape_interval: 5s
scrape_timeout: 5s
metrics_path: /metrics
scheme: http
follow_redirects: true
enable_http2: true
metric_relabel_configs:
- separator: ;
- action: labeldrop
regex: version
replacement: $1
action: labeldrop
scrape_interval: 5s
static_configs:
- targets:
- localhost:8080
- job_name: kubiznetes
honor_timestamps: true
scrape_interval: 10s
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
follow_redirects: true
enable_http2: true
kubernetes_sd_configs:
- role: node
kubeconfig_file: ""
follow_redirects: true
enable_http2: true
scrape_interval: 10s
27 changes: 3 additions & 24 deletions config/testdata/follower_no_leader_result.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,13 @@
global:
scrape_interval: 1m
scrape_timeout: 10s
evaluation_interval: 1m
scrape_configs:
- job_name: foobar
honor_timestamps: true
scrape_interval: 5s
scrape_timeout: 5s
metrics_path: /metrics
scheme: http
follow_redirects: true
enable_http2: true
metric_relabel_configs:
- separator: ;
- action: labeldrop
regex: version
replacement: $1
action: labeldrop
scrape_interval: 5s
static_configs:
- targets:
- localhost:8080
- job_name: kubiznetes
honor_timestamps: true
scrape_interval: 10s
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
follow_redirects: true
enable_http2: true
kubernetes_sd_configs:
- role: node
kubeconfig_file: ""
follow_redirects: true
enable_http2: true
scrape_interval: 10s
46 changes: 5 additions & 41 deletions config/testdata/leader_result.yaml
Original file line number Diff line number Diff line change
@@ -1,51 +1,15 @@
global:
scrape_interval: 1m
scrape_timeout: 10s
evaluation_interval: 1m
remote_write:
- url: http://remote.write.com
scrape_configs:
- job_name: foobar
honor_timestamps: true
scrape_interval: 5s
scrape_timeout: 5s
metrics_path: /metrics
scheme: http
follow_redirects: true
enable_http2: true
metric_relabel_configs:
- separator: ;
- action: labeldrop
regex: version
replacement: $1
action: labeldrop
scrape_interval: 5s
static_configs:
- targets:
- localhost:8080
- job_name: kubiznetes
honor_timestamps: true
scrape_interval: 10s
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
follow_redirects: true
enable_http2: true
kubernetes_sd_configs:
- role: node
kubeconfig_file: ""
follow_redirects: true
enable_http2: true
remote_write:
- url: http://remote.write.com
remote_timeout: 30s
follow_redirects: true
enable_http2: true
queue_config:
capacity: 10000
max_shards: 50
min_shards: 1
max_samples_per_send: 2000
batch_send_deadline: 5s
min_backoff: 30ms
max_backoff: 5s
metadata_config:
send: true
send_interval: 1m
max_samples_per_send: 2000
scrape_interval: 10s
2 changes: 1 addition & 1 deletion example/k8s/storage/storage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ spec:
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
image: quay.io/prometheus/prometheus:v2.40.4
image: quay.io/prometheus/prometheus:v2.44.0
imagePullPolicy: IfNotPresent
args:
- --config.file=/etc/config/prometheus.yaml
Expand Down
78 changes: 0 additions & 78 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/fsnotify/fsnotify v1.6.0
github.com/imdario/mergo v0.3.15
github.com/prometheus/client_golang v1.15.1
github.com/prometheus/prometheus v0.44.0
github.com/stretchr/testify v1.8.3
golang.org/x/net v0.10.0
golang.org/x/sync v0.2.0
Expand All @@ -17,118 +16,41 @@ require (
)

require (
cloud.google.com/go/compute v1.19.3 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.29 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.23 // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect
github.com/Azure/go-autorest/autorest/validation v0.3.1 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/aws/aws-sdk-go v1.44.268 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cncf/xds/go v0.0.0-20230428030218-4003588d1b74 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/digitalocean/godo v1.99.0 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker v24.0.1+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/envoyproxy/go-control-plane v0.11.0 // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.1 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-resty/resty/v2 v2.7.0 // indirect
github.com/go-zookeeper/zk v1.0.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/s2a-go v0.1.4 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.9.1 // indirect
github.com/gophercloud/gophercloud v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd // indirect
github.com/hashicorp/consul/api v1.20.0 // indirect
github.com/hashicorp/cronexpr v1.1.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.2 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/golang-lru v0.6.0 // indirect
github.com/hashicorp/nomad/api v0.0.0-20230523202910-9ff1d927d9f7 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/hetznercloud/hcloud-go v1.45.1 // indirect
github.com/ionos-cloud/sdk-go/v6 v6.1.6 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kolo/xmlrpc v0.0.0-20220921171641-a4b6fa1dd06b // indirect
github.com/linode/linodego v1.16.2 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/miekg/dns v1.1.54 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/ovh/go-ovh v1.4.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/common/sigv4 v0.1.0 // indirect
github.com/prometheus/procfs v0.10.0 // indirect
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.17 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/vultr/govultr/v2 v2.17.2 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.9.1 // indirect
google.golang.org/api v0.124.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.55.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.27.2 // indirect
k8s.io/kube-openapi v0.0.0-20230523194449-df37dd07aa00 // indirect
Expand Down
Loading

0 comments on commit 498c417

Please sign in to comment.