Skip to content

Commit

Permalink
Dev.dynamic configuration (#1429)
Browse files Browse the repository at this point in the history
* Merge main -> dev.dynamic_configuration (#1270)

* Update node_exporter dependency to v1.3.1 (#1228)

* Add node_exporter to depcheck

* update weaveworks/common dependency

* map current release flags and changed defaults

* documentation

* revert accidental checkin

* print out flags when node_exporter test fails to assist debugging

* oops, i introduced some flags from master by mistake

* Introduce experimental integrations revamp (#1198)

* [dev.multiple-integrations] Enable present integrations by default, deprecate enabled field (#1062)

* integrations: default to enabled by default

* document deprecation of enabled

* pkg/integrations: support *_configs field for integrations (#1130)

Creates the basic code to unmarshal integrations from a YAML field
called <integration name>_configs, which is a slice of that integration.

Note that this is NOT wired up to the integrations manager yet, and
trying to run the agent with more than one integration of the same type
will likely cause problems.

* [dev.multiple-integrations] Prototype new integrations subsystem (#1142)

* wip: prototype new integrations subsystem

* implement Controller with basic logic for Integration and UpdateIntegration

* Implement HTTPIntegration for Controller

* decouple controller and subsystem

* don't have controller implement integration

slightly less smelly now

* multiplexer integration

* rely on boilerplate for multiplexing for now

generics would be nice here

* remove multiplex_integration.go

Also a little code smelly. Instead of having integrations that run other
integrations, I'm going to fall back to having only one controller.

* introduce Subsystem, unexport Controller

start wiring up things to Subsystem

* introduce v2 agent integration to use for testing

* start wiring metrics integrations

* rename Options to Globals

call a spade a spade

* add subsystem options to globals

* remove dead code

* metricsutils: calculate self-scraping based on globals

* complete HTTP target API

* working example with agent integration

* appease the linter

* don't return an error when context to cancel an integration is closed

* once again i am asking the linter to forgive my typos

* fix bug where labels from individual targets were getting dropped at the API endpoint

* pkg/config: fix broken test

* finish unit tests for integrations v2 controller

* metricsutil/metricshandler_integration: make job name unique

Before this change, the job name would have collided when using multiple
instances of the same integration.

* ensure that global subsystem labels are injected into targets

* integrations/v2: Infer target hostname from SD API host (#1175)

* [dev.multiple-integrations] integrations/v2: allow shimming between v1 and v2 integrations. (#1179)

* integrations/v2: allow shimming between v1 and v2 integrations.

Shimming is done by changing how the integration registration works; a
new RegisterDynamic was added that allows for creating Configs at
runtime. Here be dragons; this should be removed whenever we no longer
have a need for it.

* fix lint

* pkg/integrations/v2: use "RegisterLegacy" instead of a generic mechanism

* fine, I won't add the deprecation notice if it will make the linter sad

* pkg/integrations: re-align (#1181)

This commit reverts 69ba2ddfa9483cc8ac6e010dd7abccd319580c80 in favor of
allowing the new subsystem to handle multiple instances of integrations.

This commit also removes the wal_truncate_frequency field from
integrations as it is the only field from old integrations that does not
have a current counterpart.

* [dev.multiple-integrations] Hide integrations/v2 behind a feature flag (#1185)

* feature flag wip

* dynamically switch between integrations v1 and v2

default to v1.

* pkg/integrations/versionselector to file in pkg/config

* pkg/config: fix defaults for Integrations

* pkg/config: use more generic way to unmarshal differently based on flag

* add missing godoc comment

* more comments

* switch to deferred unmarshaling

* remove unused Config field

* simplify completeUnmarshal

* do not perform lazy deferred unmarshaling

* enable cadvisor by default

* switch to using real feature flag

* fix postgres_exporter

* Merge main into dev.multiple-integrations (#1184)

* Fix typo (#1141)

* Traces: Improved pod association in PromSD processor (#1137)

* Improve k8s pod association

* Add tests

* Changelog

* typo

* Add prom_sd_pod_association

* Extend tests for pod associations

* Docs for pod association config

* Lint fixes

* Move to unreleased

* Add instrumentation recommendations

* Remove uncessary constants

* Improve tests

* remote config with http(s) provider (#1143)

* sample remote config code with http provider

* use t.TempDir() in unit test

* no need to clean up after T.TempDir()

* use NewClientFromConfig and make caller responsible for calling SetDirectory

* handle nil HTTPClientConfig

* remove blank identifier assignment

* pass basic auth command line flags for remote config

* address pr nits

* add expiremental flag

* set loader inline

* update changelog

* add remote config section in docs

* pr comment updates

* announce patch releases for cve-2021-41090 (#1152)

* Merge patch release to main (#1153)

* Add secret type to sensitive values

* Break out config tests to their own implementation. Also remove username has a sensitive value.

* Update changelog

* Fix failing test

* Scrub secrets when marshaling instance configs

* update for v0.21

* Updated changes from the merge.

* Remove changelog

* Scrub out receivers has ***receivers_scrubber***:null

* obscure etcd/consul credentials

* Update pkg/traces/config_test.go

Co-authored-by: Robert Fratto <robert.fratto@grafana.com>

* Update pkg/config/config.go

* go fmt

* Change to using custom object and return <secret>

* Fix bad merge

* [v0.21.2] toggle config endpoint (#19)

* disable /-/config endpoint by default

* disable scraping api get endpoint as well

* fix new test

* add test and rename flag

Co-authored-by: Robert Fratto <robertfratto@gmail.com>

* Update version to v0.21.2

* Update defaults.go

* fix /-/config endpoint

* also fix non-pointer config bug

* temporarily disable linting for release

* fix lint errors

Co-authored-by: Matt Durham <mattdurham@ppog.org>
Co-authored-by: Robert Lankford <robert.lankford@grafana.com>

* Fix POSTGRES_EXPORTER_DATA_SOURCE_NAME usage for postgres_exporter (#1162)

* Fix POSTGRES_EXPORTER_DATA_SOURCE_NAME usage for postgres_exporter

A recent change broke the usage of POSTGRES_EXPORTER_DATA_SOURCE_NAME for the postgres_exporter.
As the incorrect variable was checked in the if clause, it always raises an error.

* changelog: keep feature -> enhancement -> bugfix order

* postgres_exporter: add regression test

Co-authored-by: f11r <f11r@users.noreply.github.com>
Co-authored-by: Robert Fratto <robertfratto@gmail.com>

* Fix syntax error in Jsonnet logs helper method (#1174)

Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>

* cAdvisor Integration (#1081)

* Add cadvisor module

* Begin creating common config for cadvisor

* Don't export internal state

* Finish config options for cadvisor

* Set config options, and implement cAdvisor collectors

* Linting

* Buildflags for cadvisor only in linux

* I R LEArN Build Tags

* Don't zero value the zero value

* Offload sketchy global var manipulation to the integrations Run func

* Remove unused collectors

* Lint

* Create generic stub integration and use it for cadvisor

* Lint

* Final refactor of cAdvisor config for unsupported platforms. Pared down stub integrations.

* Lint

* Docs for cadvisor config

* Update changelog

* Update pkg/integrations/stub_integration.go

Co-authored-by: Robert Fratto <robert.fratto@grafana.com>

* Reorder changelog

* Instance key clarity

* Inclusive naming

* Finish name changes

Keep default disable metric list in sync with upstream

Idiomatic golang

* Hardcode disabled metrics for cadvisor

Co-authored-by: Robert Fratto <robert.fratto@grafana.com>

* Remove log-level flag from systemd unit file (#1177)

* Upgrade to OTel v0.40.0 (#1176)

* Upgrade to OTel v0.40.0

* Changelog

* Add factories check

* go mod tidy

* config/features: create package to standardize experimental features (#1170)

* config/features: create package to standardize experiemental features

This commit introduces a new package, pkg/config/features, which allows
defining a set of features and validating whether flags associated with
those features are allowed to be set.

Closes #1163

* update documentation

(also s/enabled-features/enable-features)

* Fix typo

* Update pkg/config/features/features.go

Co-authored-by: Robert Lankford <rlankfo@gmail.com>

Co-authored-by: Robert Lankford <rlankfo@gmail.com>

* enable cadvisor by default

* switch to using real feature flag

* fix postgres_exporter

Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com>
Co-authored-by: Mario <mariorvinas@gmail.com>
Co-authored-by: Robert Lankford <robert.lankford@grafana.com>
Co-authored-by: Matt Durham <mattdurham@ppog.org>
Co-authored-by: f11r <fiete.gruenter@rwth-aachen.de>
Co-authored-by: f11r <f11r@users.noreply.github.com>
Co-authored-by: Nick Pillitteri <56quarters@users.noreply.github.com>
Co-authored-by: Ryan Geyer <me@ryangeyer.com>
Co-authored-by: Juraci Paixão Kröhling <juraci.github@kroehling.de>
Co-authored-by: Robert Lankford <rlankfo@gmail.com>

* Revert "Merge main into dev.multiple-integrations (#1184)" (#1189)

This reverts commit ad76ec54f9a781fc83d3e7001808c887f37833ff.

* [dev.multiple-integrations] Revert breaking changes to existing integrations (#1191)

* revert breaking changes to integrations v1

This commit reverts #1062 in favor of making breaking changes directly
in integrations-next instead. The part of #1181 to remove
`wal_truncate_frequency` has also been reverted.

As part of this change, the enabled field is removed from the v2
common metrics configs, and v2 integrations can no longer be disabled.
v2 integrations can only be disabled by removing them from the YAML.

* integrations/v2: remove stale reference to ErrDisabled

(fix typo too)

* integrations/v2: bring in common config decoupling

* [dev.multiple-integrations] Introduce autoscraper (#1195)

* pkg/integrations/v2: introduce self-scraping

* linting

* [dev.multiple-integrations] Multiple instances of integrations (#1196)

* multiple instances of integrations

opt in relevant v1 integrations into supporting multiple instances

* shims should check for instance key override

* Document integrations-next (#1197)

* document integrations-next

* remove json tags since they make markdown unhappy

* changelog

* s/Run/RunIntegration

* remove stale comment about integrations.controller purpose

* create dedicated run method for instanceScraper

* s/expoter/exporter/g

* Document why an autoscrape.Scraper manages a set of per-instance scrapers

* spell out prerequisite instead of pre-req

* use go.uber.org/atomic to make the code a little easier to follow

* remove started callback for running integration

* use smaller interface for autoscrape

Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com>
Co-authored-by: Mario <mariorvinas@gmail.com>
Co-authored-by: Robert Lankford <robert.lankford@grafana.com>
Co-authored-by: Matt Durham <mattdurham@ppog.org>
Co-authored-by: f11r <fiete.gruenter@rwth-aachen.de>
Co-authored-by: f11r <f11r@users.noreply.github.com>
Co-authored-by: Nick Pillitteri <56quarters@users.noreply.github.com>
Co-authored-by: Ryan Geyer <me@ryangeyer.com>
Co-authored-by: Juraci Paixão Kröhling <juraci.github@kroehling.de>
Co-authored-by: Robert Lankford <rlankfo@gmail.com>

* Fix panic when using 'stdout' in automatic logging (#1233)

* integrations-next: fix bug where v2 integrations were not being strictly unmarshaled (#1235)

* Remove jsonnet vendor folders (#1222)

* remove jsonnet vendor

This adds all vendor folders into .gitignore and removes cached vendor
files from the repository.

Closes #1221

* Update scripts and instructions for jsonnet vendor removal

* `make example-dashboards` will now also run `jb install`
* k3d environment instructions now include `jb install`
* smoke-test.bash will now run `jb install` prior to `tk apply`

* Fix link to k3d example in DEVELOPERS.md (#1242)

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Fix node_exporter upgrade docs (#1239)

* Fix panic in automatic logging with stdout backend (#1243)

* pkg/util: support custom yaml.Unmarshaler implementations for util.UnmarshalYAMLMerged (#1244)

It's common for config types to have implement yaml.Unmarshaler for:

* Applying defaults
* Applying extra logic post-unmarshal

If these config types were unmarshaled through util.UnmarshalYAMLMerged,
the yaml.Unmarshaler implementation would never complete successfully,
preventing the post-unmarshal logic from running.

This issue was introduced in #1192, but went unnoticed until #1228
implemented yaml.Unmarshaler to perform field migrations. #1240 reported
the issue.

This commit fixes the bug by performing a second non-strict unmarshal to
ensure that all input values unmarshal successfully, with the exception
of unmarshal errors unrelated to unrecognized field names.

This is hacky, but it's worthwhile noting that util.UnmarshalYAMLMerged
is a temporary workaround needed for the integrations-next migration,
and will eventually be removed.

* Update k3d example grafana/grafonnet-lib version (#1246)

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Create an e2e framework with support for running tests against k8s (#1234)

* e2e: create an e2e framework with support for running tests against a k3d cluster

* add new E2E drone job

* E2E tests should pass when doing a release

* sign drone.yml again

* move e2e lint to different step that has golangci-lint installed

* upgrade golangci-lint and go for e2e test

* e2e: add gcc

* E2E: install build-essential to get a working full gcc env

* :(

* e2e: support running from inside of docker

* fix lint error

* address review feedback

* Operator: fix bug where /-/ready and /-/healthy always returned 404 (#1252)

* operator: fix bug where /-/ready and /-/healthy always returned 404

controller-runtime must have at least one ready/healthy check for the endpoints to exist

* fix lint error, use healthz.Ping

* Make scraping-svc use the new `metrics:` key (#1259)

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* update prometheus dependency (#1260)

* corrected typo (#1265)

* Use RELEASE_TAG to choose between `:main` and `:latest` docker tags (#1264)

* Use RELEASE_TAG to choose between `:main` and `:latest` docker tags

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Use :main tag for images in smoke test

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Set IMAGE_BRANCH_TAG env var in drone and actions pipelines

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Remove quotes from Makefile variable

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Remove force_release action

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* prepare for v0.22.0 release (#1266)

* prepare for v0.22.0 release

* remove E2E pipeline

Co-authored-by: Robert Fratto <robert.fratto@grafana.com>
Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com>
Co-authored-by: Mario <mariorvinas@gmail.com>
Co-authored-by: Robert Lankford <robert.lankford@grafana.com>
Co-authored-by: f11r <fiete.gruenter@rwth-aachen.de>
Co-authored-by: f11r <f11r@users.noreply.github.com>
Co-authored-by: Nick Pillitteri <56quarters@users.noreply.github.com>
Co-authored-by: Ryan Geyer <me@ryangeyer.com>
Co-authored-by: Juraci Paixão Kröhling <juraci.github@kroehling.de>
Co-authored-by: Robert Lankford <rlankfo@gmail.com>
Co-authored-by: Paschalis Tsilias <tpaschalis@users.noreply.github.com>
Co-authored-by: Patrick Koenig <pkoenig10@gmail.com>
Co-authored-by: DataPoints <langer.markus@gmail.com>

* Main merge dynamic (#1305)

* Update node_exporter dependency to v1.3.1 (#1228)

* Add node_exporter to depcheck

* update weaveworks/common dependency

* map current release flags and changed defaults

* documentation

* revert accidental checkin

* print out flags when node_exporter test fails to assist debugging

* oops, i introduced some flags from master by mistake

* Introduce experimental integrations revamp (#1198)

* [dev.multiple-integrations] Enable present integrations by default, deprecate enabled field (#1062)

* integrations: default to enabled by default

* document deprecation of enabled

* pkg/integrations: support *_configs field for integrations (#1130)

Creates the basic code to unmarshal integrations from a YAML field
called <integration name>_configs, which is a slice of that integration.

Note that this is NOT wired up to the integrations manager yet, and
trying to run the agent with more than one integration of the same type
will likely cause problems.

* [dev.multiple-integrations] Prototype new integrations subsystem (#1142)

* wip: prototype new integrations subsystem

* implement Controller with basic logic for Integration and UpdateIntegration

* Implement HTTPIntegration for Controller

* decouple controller and subsystem

* don't have controller implement integration

slightly less smelly now

* multiplexer integration

* rely on boilerplate for multiplexing for now

generics would be nice here

* remove multiplex_integration.go

Also a little code smelly. Instead of having integrations that run other
integrations, I'm going to fall back to having only one controller.

* introduce Subsystem, unexport Controller

start wiring up things to Subsystem

* introduce v2 agent integration to use for testing

* start wiring metrics integrations

* rename Options to Globals

call a spade a spade

* add subsystem options to globals

* remove dead code

* metricsutils: calculate self-scraping based on globals

* complete HTTP target API

* working example with agent integration

* appease the linter

* don't return an error when context to cancel an integration is closed

* once again i am asking the linter to forgive my typos

* fix bug where labels from individual targets were getting dropped at the API endpoint

* pkg/config: fix broken test

* finish unit tests for integrations v2 controller

* metricsutil/metricshandler_integration: make job name unique

Before this change, the job name would have collided when using multiple
instances of the same integration.

* ensure that global subsystem labels are injected into targets

* integrations/v2: Infer target hostname from SD API host (#1175)

* [dev.multiple-integrations] integrations/v2: allow shimming between v1 and v2 integrations. (#1179)

* integrations/v2: allow shimming between v1 and v2 integrations.

Shimming is done by changing how the integration registration works; a
new RegisterDynamic was added that allows for creating Configs at
runtime. Here be dragons; this should be removed whenever we no longer
have a need for it.

* fix lint

* pkg/integrations/v2: use "RegisterLegacy" instead of a generic mechanism

* fine, I won't add the deprecation notice if it will make the linter sad

* pkg/integrations: re-align (#1181)

This commit reverts 69ba2ddfa9483cc8ac6e010dd7abccd319580c80 in favor of
allowing the new subsystem to handle multiple instances of integrations.

This commit also removes the wal_truncate_frequency field from
integrations as it is the only field from old integrations that does not
have a current counterpart.

* [dev.multiple-integrations] Hide integrations/v2 behind a feature flag (#1185)

* feature flag wip

* dynamically switch between integrations v1 and v2

default to v1.

* pkg/integrations/versionselector to file in pkg/config

* pkg/config: fix defaults for Integrations

* pkg/config: use more generic way to unmarshal differently based on flag

* add missing godoc comment

* more comments

* switch to deferred unmarshaling

* remove unused Config field

* simplify completeUnmarshal

* do not perform lazy deferred unmarshaling

* enable cadvisor by default

* switch to using real feature flag

* fix postgres_exporter

* Merge main into dev.multiple-integrations (#1184)

* Fix typo (#1141)

* Traces: Improved pod association in PromSD processor (#1137)

* Improve k8s pod association

* Add tests

* Changelog

* typo

* Add prom_sd_pod_association

* Extend tests for pod associations

* Docs for pod association config

* Lint fixes

* Move to unreleased

* Add instrumentation recommendations

* Remove uncessary constants

* Improve tests

* remote config with http(s) provider (#1143)

* sample remote config code with http provider

* use t.TempDir() in unit test

* no need to clean up after T.TempDir()

* use NewClientFromConfig and make caller responsible for calling SetDirectory

* handle nil HTTPClientConfig

* remove blank identifier assignment

* pass basic auth command line flags for remote config

* address pr nits

* add expiremental flag

* set loader inline

* update changelog

* add remote config section in docs

* pr comment updates

* announce patch releases for cve-2021-41090 (#1152)

* Merge patch release to main (#1153)

* Add secret type to sensitive values

* Break out config tests to their own implementation. Also remove username has a sensitive value.

* Update changelog

* Fix failing test

* Scrub secrets when marshaling instance configs

* update for v0.21

* Updated changes from the merge.

* Remove changelog

* Scrub out receivers has ***receivers_scrubber***:null

* obscure etcd/consul credentials

* Update pkg/traces/config_test.go

Co-authored-by: Robert Fratto <robert.fratto@grafana.com>

* Update pkg/config/config.go

* go fmt

* Change to using custom object and return <secret>

* Fix bad merge

* [v0.21.2] toggle config endpoint (#19)

* disable /-/config endpoint by default

* disable scraping api get endpoint as well

* fix new test

* add test and rename flag

Co-authored-by: Robert Fratto <robertfratto@gmail.com>

* Update version to v0.21.2

* Update defaults.go

* fix /-/config endpoint

* also fix non-pointer config bug

* temporarily disable linting for release

* fix lint errors

Co-authored-by: Matt Durham <mattdurham@ppog.org>
Co-authored-by: Robert Lankford <robert.lankford@grafana.com>

* Fix POSTGRES_EXPORTER_DATA_SOURCE_NAME usage for postgres_exporter (#1162)

* Fix POSTGRES_EXPORTER_DATA_SOURCE_NAME usage for postgres_exporter

A recent change broke the usage of POSTGRES_EXPORTER_DATA_SOURCE_NAME for the postgres_exporter.
As the incorrect variable was checked in the if clause, it always raises an error.

* changelog: keep feature -> enhancement -> bugfix order

* postgres_exporter: add regression test

Co-authored-by: f11r <f11r@users.noreply.github.com>
Co-authored-by: Robert Fratto <robertfratto@gmail.com>

* Fix syntax error in Jsonnet logs helper method (#1174)

Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>

* cAdvisor Integration (#1081)

* Add cadvisor module

* Begin creating common config for cadvisor

* Don't export internal state

* Finish config options for cadvisor

* Set config options, and implement cAdvisor collectors

* Linting

* Buildflags for cadvisor only in linux

* I R LEArN Build Tags

* Don't zero value the zero value

* Offload sketchy global var manipulation to the integrations Run func

* Remove unused collectors

* Lint

* Create generic stub integration and use it for cadvisor

* Lint

* Final refactor of cAdvisor config for unsupported platforms. Pared down stub integrations.

* Lint

* Docs for cadvisor config

* Update changelog

* Update pkg/integrations/stub_integration.go

Co-authored-by: Robert Fratto <robert.fratto@grafana.com>

* Reorder changelog

* Instance key clarity

* Inclusive naming

* Finish name changes

Keep default disable metric list in sync with upstream

Idiomatic golang

* Hardcode disabled metrics for cadvisor

Co-authored-by: Robert Fratto <robert.fratto@grafana.com>

* Remove log-level flag from systemd unit file (#1177)

* Upgrade to OTel v0.40.0 (#1176)

* Upgrade to OTel v0.40.0

* Changelog

* Add factories check

* go mod tidy

* config/features: create package to standardize experimental features (#1170)

* config/features: create package to standardize experiemental features

This commit introduces a new package, pkg/config/features, which allows
defining a set of features and validating whether flags associated with
those features are allowed to be set.

Closes #1163

* update documentation

(also s/enabled-features/enable-features)

* Fix typo

* Update pkg/config/features/features.go

Co-authored-by: Robert Lankford <rlankfo@gmail.com>

Co-authored-by: Robert Lankford <rlankfo@gmail.com>

* enable cadvisor by default

* switch to using real feature flag

* fix postgres_exporter

Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com>
Co-authored-by: Mario <mariorvinas@gmail.com>
Co-authored-by: Robert Lankford <robert.lankford@grafana.com>
Co-authored-by: Matt Durham <mattdurham@ppog.org>
Co-authored-by: f11r <fiete.gruenter@rwth-aachen.de>
Co-authored-by: f11r <f11r@users.noreply.github.com>
Co-authored-by: Nick Pillitteri <56quarters@users.noreply.github.com>
Co-authored-by: Ryan Geyer <me@ryangeyer.com>
Co-authored-by: Juraci Paixão Kröhling <juraci.github@kroehling.de>
Co-authored-by: Robert Lankford <rlankfo@gmail.com>

* Revert "Merge main into dev.multiple-integrations (#1184)" (#1189)

This reverts commit ad76ec54f9a781fc83d3e7001808c887f37833ff.

* [dev.multiple-integrations] Revert breaking changes to existing integrations (#1191)

* revert breaking changes to integrations v1

This commit reverts #1062 in favor of making breaking changes directly
in integrations-next instead. The part of #1181 to remove
`wal_truncate_frequency` has also been reverted.

As part of this change, the enabled field is removed from the v2
common metrics configs, and v2 integrations can no longer be disabled.
v2 integrations can only be disabled by removing them from the YAML.

* integrations/v2: remove stale reference to ErrDisabled

(fix typo too)

* integrations/v2: bring in common config decoupling

* [dev.multiple-integrations] Introduce autoscraper (#1195)

* pkg/integrations/v2: introduce self-scraping

* linting

* [dev.multiple-integrations] Multiple instances of integrations (#1196)

* multiple instances of integrations

opt in relevant v1 integrations into supporting multiple instances

* shims should check for instance key override

* Document integrations-next (#1197)

* document integrations-next

* remove json tags since they make markdown unhappy

* changelog

* s/Run/RunIntegration

* remove stale comment about integrations.controller purpose

* create dedicated run method for instanceScraper

* s/expoter/exporter/g

* Document why an autoscrape.Scraper manages a set of per-instance scrapers

* spell out prerequisite instead of pre-req

* use go.uber.org/atomic to make the code a little easier to follow

* remove started callback for running integration

* use smaller interface for autoscrape

Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com>
Co-authored-by: Mario <mariorvinas@gmail.com>
Co-authored-by: Robert Lankford <robert.lankford@grafana.com>
Co-authored-by: Matt Durham <mattdurham@ppog.org>
Co-authored-by: f11r <fiete.gruenter@rwth-aachen.de>
Co-authored-by: f11r <f11r@users.noreply.github.com>
Co-authored-by: Nick Pillitteri <56quarters@users.noreply.github.com>
Co-authored-by: Ryan Geyer <me@ryangeyer.com>
Co-authored-by: Juraci Paixão Kröhling <juraci.github@kroehling.de>
Co-authored-by: Robert Lankford <rlankfo@gmail.com>

* Fix panic when using 'stdout' in automatic logging (#1233)

* integrations-next: fix bug where v2 integrations were not being strictly unmarshaled (#1235)

* Remove jsonnet vendor folders (#1222)

* remove jsonnet vendor

This adds all vendor folders into .gitignore and removes cached vendor
files from the repository.

Closes #1221

* Update scripts and instructions for jsonnet vendor removal

* `make example-dashboards` will now also run `jb install`
* k3d environment instructions now include `jb install`
* smoke-test.bash will now run `jb install` prior to `tk apply`

* Fix link to k3d example in DEVELOPERS.md (#1242)

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Fix node_exporter upgrade docs (#1239)

* Fix panic in automatic logging with stdout backend (#1243)

* pkg/util: support custom yaml.Unmarshaler implementations for util.UnmarshalYAMLMerged (#1244)

It's common for config types to have implement yaml.Unmarshaler for:

* Applying defaults
* Applying extra logic post-unmarshal

If these config types were unmarshaled through util.UnmarshalYAMLMerged,
the yaml.Unmarshaler implementation would never complete successfully,
preventing the post-unmarshal logic from running.

This issue was introduced in #1192, but went unnoticed until #1228
implemented yaml.Unmarshaler to perform field migrations. #1240 reported
the issue.

This commit fixes the bug by performing a second non-strict unmarshal to
ensure that all input values unmarshal successfully, with the exception
of unmarshal errors unrelated to unrecognized field names.

This is hacky, but it's worthwhile noting that util.UnmarshalYAMLMerged
is a temporary workaround needed for the integrations-next migration,
and will eventually be removed.

* Update k3d example grafana/grafonnet-lib version (#1246)

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Create an e2e framework with support for running tests against k8s (#1234)

* e2e: create an e2e framework with support for running tests against a k3d cluster

* add new E2E drone job

* E2E tests should pass when doing a release

* sign drone.yml again

* move e2e lint to different step that has golangci-lint installed

* upgrade golangci-lint and go for e2e test

* e2e: add gcc

* E2E: install build-essential to get a working full gcc env

* :(

* e2e: support running from inside of docker

* fix lint error

* address review feedback

* Operator: fix bug where /-/ready and /-/healthy always returned 404 (#1252)

* operator: fix bug where /-/ready and /-/healthy always returned 404

controller-runtime must have at least one ready/healthy check for the endpoints to exist

* fix lint error, use healthz.Ping

* Make scraping-svc use the new `metrics:` key (#1259)

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* update prometheus dependency (#1260)

* corrected typo (#1265)

* Use RELEASE_TAG to choose between `:main` and `:latest` docker tags (#1264)

* Use RELEASE_TAG to choose between `:main` and `:latest` docker tags

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Use :main tag for images in smoke test

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Set IMAGE_BRANCH_TAG env var in drone and actions pipelines

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Remove quotes from Makefile variable

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Remove force_release action

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* prepare for v0.22.0 release (#1266)

* prepare for v0.22.0 release

* remove E2E pipeline

* Add basic testing framework for operator (#1268)

* remove dedicated go.mod for e2e/

* move e2e/k8s to pkg/util/k8s

* Migrate operator tests to pkg/util/k8s

* remove dedicated e2e tests

* allow skipping TestCluster in pkg/util/k8s

* remove e2e/

* fix bad merge

* fix order of make env args for windows

* actually declare referenced docker volume

* introduce pkg/util/subset for asserting subset of objects

* refactor operator so it's testable

* define basic integration test for operator

* fix lint errors

* fix invalid address in operator test config

* Update release-note.md (#1267)

* Set scrape User-Agent header during init (#1274)

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Upgrade to Go 1.17 (#1278)

* Upgrade to 1.17.6 in go.mod and Dockerfiles

* Update CHANGELOG.md to mention the update

* Update Go version in drone/actions pipelines

* Update go.mod, go.sum files via

* Re-sign drone.yml

* Remove leading newline causing drone build to fail

* Bump golangci-lint image to a version using Go 1.17

* Re-attempt to solve linter issue with new golangci-lint image

* Remove suffix of exclude rules

* Clean previous Go version before unpacking Go 1.17

* Also clean up previous Go versions in other steps

* fix typo (#1284)

* Use custom Go version in agent-operator Dockerfile (#1286)

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* pkg/operator: refactor resource hierarchy discovery (#1271)

* pkg/operator: refactor resource hierarchy discovery

This commit moves common logic related to discovering the resource
hierarchy to pkg/operator/hierarchy. This new package requires less
boilerplate, which the reconciler is updated to take advantage of.

* remove unused code

* test construction of resource hierarchy

* add missing build constraints

* small extra cleanup to use pointer package

* review feedback

* update agent-build-image for go 1.17 (#1287)

(also use a consistent base image tag instead of latest)

* Skip non-ready entries when listing instances (#1289)

* Skip non-ready instances in LoadInstances()

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Add changelog entry

Co-authored-by: Robert Fratto <robertfratto@gmail.com>

* Fix panic in prom_sd_processor when address is empty (#1279)

* Fix panic in prom_sd_processor when address is empty

* Fix panic in prom_sd_processor when address is empty

* Fix docs

* Add test case

* Lint

* Move to unreleased

* Operator: generate proxy_url for remote_write (#1298)

* operator: generate proxy_url for remote_write

* fix weird indentation in test

Co-authored-by: Robert Fratto <robert.fratto@grafana.com>
Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com>
Co-authored-by: Mario <mariorvinas@gmail.com>
Co-authored-by: Robert Lankford <robert.lankford@grafana.com>
Co-authored-by: f11r <fiete.gruenter@rwth-aachen.de>
Co-authored-by: f11r <f11r@users.noreply.github.com>
Co-authored-by: Nick Pillitteri <56quarters@users.noreply.github.com>
Co-authored-by: Ryan Geyer <me@ryangeyer.com>
Co-authored-by: Juraci Paixão Kröhling <juraci.github@kroehling.de>
Co-authored-by: Robert Lankford <rlankfo@gmail.com>
Co-authored-by: Paschalis Tsilias <tpaschalis@users.noreply.github.com>
Co-authored-by: Patrick Koenig <pkoenig10@gmail.com>
Co-authored-by: DataPoints <langer.markus@gmail.com>
Co-authored-by: Alex <52292902+alexrudd2@users.noreply.github.com>
Co-authored-by: Robert Fratto <robertfratto@gmail.com>

* Main merge dynamic (#1307)

* Update node_exporter dependency to v1.3.1 (#1228)

* Add node_exporter to depcheck

* update weaveworks/common dependency

* map current release flags and changed defaults

* documentation

* revert accidental checkin

* print out flags when node_exporter test fails to assist debugging

* oops, i introduced some flags from master by mistake

* Introduce experimental integrations revamp (#1198)

* [dev.multiple-integrations] Enable present integrations by default, deprecate enabled field (#1062)

* integrations: default to enabled by default

* document deprecation of enabled

* pkg/integrations: support *_configs field for integrations (#1130)

Creates the basic code to unmarshal integrations from a YAML field
called <integration name>_configs, which is a slice of that integration.

Note that this is NOT wired up to the integrations manager yet, and
trying to run the agent with more than one integration of the same type
will likely cause problems.

* [dev.multiple-integrations] Prototype new integrations subsystem (#1142)

* wip: prototype new integrations subsystem

* implement Controller with basic logic for Integration and UpdateIntegration

* Implement HTTPIntegration for Controller

* decouple controller and subsystem

* don't have controller implement integration

slightly less smelly now

* multiplexer integration

* rely on boilerplate for multiplexing for now

generics would be nice here

* remove multiplex_integration.go

Also a little code smelly. Instead of having integrations that run other
integrations, I'm going to fall back to having only one controller.

* introduce Subsystem, unexport Controller

start wiring up things to Subsystem

* introduce v2 agent integration to use for testing

* start wiring metrics integrations

* rename Options to Globals

call a spade a spade

* add subsystem options to globals

* remove dead code

* metricsutils: calculate self-scraping based on globals

* complete HTTP target API

* working example with agent integration

* appease the linter

* don't return an error when context to cancel an integration is closed

* once again i am asking the linter to forgive my typos

* fix bug where labels from individual targets were getting dropped at the API endpoint

* pkg/config: fix broken test

* finish unit tests for integrations v2 controller

* metricsutil/metricshandler_integration: make job name unique

Before this change, the job name would have collided when using multiple
instances of the same integration.

* ensure that global subsystem labels are injected into targets

* integrations/v2: Infer target hostname from SD API host (#1175)

* [dev.multiple-integrations] integrations/v2: allow shimming between v1 and v2 integrations. (#1179)

* integrations/v2: allow shimming between v1 and v2 integrations.

Shimming is done by changing how the integration registration works; a
new RegisterDynamic was added that allows for creating Configs at
runtime. Here be dragons; this should be removed whenever we no longer
have a need for it.

* fix lint

* pkg/integrations/v2: use "RegisterLegacy" instead of a generic mechanism

* fine, I won't add the deprecation notice if it will make the linter sad

* pkg/integrations: re-align (#1181)

This commit reverts 69ba2ddfa9483cc8ac6e010dd7abccd319580c80 in favor of
allowing the new subsystem to handle multiple instances of integrations.

This commit also removes the wal_truncate_frequency field from
integrations as it is the only field from old integrations that does not
have a current counterpart.

* [dev.multiple-integrations] Hide integrations/v2 behind a feature flag (#1185)

* feature flag wip

* dynamically switch between integrations v1 and v2

default to v1.

* pkg/integrations/versionselector to file in pkg/config

* pkg/config: fix defaults for Integrations

* pkg/config: use more generic way to unmarshal differently based on flag

* add missing godoc comment

* more comments

* switch to deferred unmarshaling

* remove unused Config field

* simplify completeUnmarshal

* do not perform lazy deferred unmarshaling

* enable cadvisor by default

* switch to using real feature flag

* fix postgres_exporter

* Merge main into dev.multiple-integrations (#1184)

* Fix typo (#1141)

* Traces: Improved pod association in PromSD processor (#1137)

* Improve k8s pod association

* Add tests

* Changelog

* typo

* Add prom_sd_pod_association

* Extend tests for pod associations

* Docs for pod association config

* Lint fixes

* Move to unreleased

* Add instrumentation recommendations

* Remove uncessary constants

* Improve tests

* remote config with http(s) provider (#1143)

* sample remote config code with http provider

* use t.TempDir() in unit test

* no need to clean up after T.TempDir()

* use NewClientFromConfig and make caller responsible for calling SetDirectory

* handle nil HTTPClientConfig

* remove blank identifier assignment

* pass basic auth command line flags for remote config

* address pr nits

* add expiremental flag

* set loader inline

* update changelog

* add remote config section in docs

* pr comment updates

* announce patch releases for cve-2021-41090 (#1152)

* Merge patch release to main (#1153)

* Add secret type to sensitive values

* Break out config tests to their own implementation. Also remove username has a sensitive value.

* Update changelog

* Fix failing test

* Scrub secrets when marshaling instance configs

* update for v0.21

* Updated changes from the merge.

* Remove changelog

* Scrub out receivers has ***receivers_scrubber***:null

* obscure etcd/consul credentials

* Update pkg/traces/config_test.go

Co-authored-by: Robert Fratto <robert.fratto@grafana.com>

* Update pkg/config/config.go

* go fmt

* Change to using custom object and return <secret>

* Fix bad merge

* [v0.21.2] toggle config endpoint (#19)

* disable /-/config endpoint by default

* disable scraping api get endpoint as well

* fix new test

* add test and rename flag

Co-authored-by: Robert Fratto <robertfratto@gmail.com>

* Update version to v0.21.2

* Update defaults.go

* fix /-/config endpoint

* also fix non-pointer config bug

* temporarily disable linting for release

* fix lint errors

Co-authored-by: Matt Durham <mattdurham@ppog.org>
Co-authored-by: Robert Lankford <robert.lankford@grafana.com>

* Fix POSTGRES_EXPORTER_DATA_SOURCE_NAME usage for postgres_exporter (#1162)

* Fix POSTGRES_EXPORTER_DATA_SOURCE_NAME usage for postgres_exporter

A recent change broke the usage of POSTGRES_EXPORTER_DATA_SOURCE_NAME for the postgres_exporter.
As the incorrect variable was checked in the if clause, it always raises an error.

* changelog: keep feature -> enhancement -> bugfix order

* postgres_exporter: add regression test

Co-authored-by: f11r <f11r@users.noreply.github.com>
Co-authored-by: Robert Fratto <robertfratto@gmail.com>

* Fix syntax error in Jsonnet logs helper method (#1174)

Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>

* cAdvisor Integration (#1081)

* Add cadvisor module

* Begin creating common config for cadvisor

* Don't export internal state

* Finish config options for cadvisor

* Set config options, and implement cAdvisor collectors

* Linting

* Buildflags for cadvisor only in linux

* I R LEArN Build Tags

* Don't zero value the zero value

* Offload sketchy global var manipulation to the integrations Run func

* Remove unused collectors

* Lint

* Create generic stub integration and use it for cadvisor

* Lint

* Final refactor of cAdvisor config for unsupported platforms. Pared down stub integrations.

* Lint

* Docs for cadvisor config

* Update changelog

* Update pkg/integrations/stub_integration.go

Co-authored-by: Robert Fratto <robert.fratto@grafana.com>

* Reorder changelog

* Instance key clarity

* Inclusive naming

* Finish name changes

Keep default disable metric list in sync with upstream

Idiomatic golang

* Hardcode disabled metrics for cadvisor

Co-authored-by: Robert Fratto <robert.fratto@grafana.com>

* Remove log-level flag from systemd unit file (#1177)

* Upgrade to OTel v0.40.0 (#1176)

* Upgrade to OTel v0.40.0

* Changelog

* Add factories check

* go mod tidy

* config/features: create package to standardize experimental features (#1170)

* config/features: create package to standardize experiemental features

This commit introduces a new package, pkg/config/features, which allows
defining a set of features and validating whether flags associated with
those features are allowed to be set.

Closes #1163

* update documentation

(also s/enabled-features/enable-features)

* Fix typo

* Update pkg/config/features/features.go

Co-authored-by: Robert Lankford <rlankfo@gmail.com>

Co-authored-by: Robert Lankford <rlankfo@gmail.com>

* enable cadvisor by default

* switch to using real feature flag

* fix postgres_exporter

Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com>
Co-authored-by: Mario <mariorvinas@gmail.com>
Co-authored-by: Robert Lankford <robert.lankford@grafana.com>
Co-authored-by: Matt Durham <mattdurham@ppog.org>
Co-authored-by: f11r <fiete.gruenter@rwth-aachen.de>
Co-authored-by: f11r <f11r@users.noreply.github.com>
Co-authored-by: Nick Pillitteri <56quarters@users.noreply.github.com>
Co-authored-by: Ryan Geyer <me@ryangeyer.com>
Co-authored-by: Juraci Paixão Kröhling <juraci.github@kroehling.de>
Co-authored-by: Robert Lankford <rlankfo@gmail.com>

* Revert "Merge main into dev.multiple-integrations (#1184)" (#1189)

This reverts commit ad76ec54f9a781fc83d3e7001808c887f37833ff.

* [dev.multiple-integrations] Revert breaking changes to existing integrations (#1191)

* revert breaking changes to integrations v1

This commit reverts #1062 in favor of making breaking changes directly
in integrations-next instead. The part of #1181 to remove
`wal_truncate_frequency` has also been reverted.

As part of this change, the enabled field is removed from the v2
common metrics configs, and v2 integrations can no longer be disabled.
v2 integrations can only be disabled by removing them from the YAML.

* integrations/v2: remove stale reference to ErrDisabled

(fix typo too)

* integrations/v2: bring in common config decoupling

* [dev.multiple-integrations] Introduce autoscraper (#1195)

* pkg/integrations/v2: introduce self-scraping

* linting

* [dev.multiple-integrations] Multiple instances of integrations (#1196)

* multiple instances of integrations

opt in relevant v1 integrations into supporting multiple instances

* shims should check for instance key override

* Document integrations-next (#1197)

* document integrations-next

* remove json tags since they make markdown unhappy

* changelog

* s/Run/RunIntegration

* remove stale comment about integrations.controller purpose

* create dedicated run method for instanceScraper

* s/expoter/exporter/g

* Document why an autoscrape.Scraper manages a set of per-instance scrapers

* spell out prerequisite instead of pre-req

* use go.uber.org/atomic to make the code a little easier to follow

* remove started callback for running integration

* use smaller interface for autoscrape

Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com>
Co-authored-by: Mario <mariorvinas@gmail.com>
Co-authored-by: Robert Lankford <robert.lankford@grafana.com>
Co-authored-by: Matt Durham <mattdurham@ppog.org>
Co-authored-by: f11r <fiete.gruenter@rwth-aachen.de>
Co-authored-by: f11r <f11r@users.noreply.github.com>
Co-authored-by: Nick Pillitteri <56quarters@users.noreply.github.com>
Co-authored-by: Ryan Geyer <me@ryangeyer.com>
Co-authored-by: Juraci Paixão Kröhling <juraci.github@kroehling.de>
Co-authored-by: Robert Lankford <rlankfo@gmail.com>

* Fix panic when using 'stdout' in automatic logging (#1233)

* integrations-next: fix bug where v2 integrations were not being strictly unmarshaled (#1235)

* Remove jsonnet vendor folders (#1222)

* remove jsonnet vendor

This adds all vendor folders into .gitignore and removes cached vendor
files from the repository.

Closes #1221

* Update scripts and instructions for jsonnet vendor removal

* `make example-dashboards` will now also run `jb install`
* k3d environment instructions now include `jb install`
* smoke-test.bash will now run `jb install` prior to `tk apply`

* Fix link to k3d example in DEVELOPERS.md (#1242)

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Fix node_exporter upgrade docs (#1239)

* Fix panic in automatic logging with stdout backend (#1243)

* pkg/util: support custom yaml.Unmarshaler implementations for util.UnmarshalYAMLMerged (#1244)

It's common for config types to have implement yaml.Unmarshaler for:

* Applying defaults
* Applying extra logic post-unmarshal

If these config types were unmarshaled through util.UnmarshalYAMLMerged,
the yaml.Unmarshaler implementation would never complete successfully,
preventing the post-unmarshal logic from running.

This issue was introduced in #1192, but went unnoticed until #1228
implemented yaml.Unmarshaler to perform field migrations. #1240 reported
the issue.

This commit fixes the bug by performing a second non-strict unmarshal to
ensure that all input values unmarshal successfully, with the exception
of unmarshal errors unrelated to unrecognized field names.

This is hacky, but it's worthwhile noting that util.UnmarshalYAMLMerged
is a temporary workaround needed for the integrations-next migration,
and will eventually be removed.

* Update k3d example grafana/grafonnet-lib version (#1246)

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Create an e2e framework with support for running tests against k8s (#1234)

* e2e: create an e2e framework with support for running tests against a k3d cluster

* add new E2E drone job

* E2E tests should pass when doing a release

* sign drone.yml again

* move e2e lint to different step that has golangci-lint installed

* upgrade golangci-lint and go for e2e test

* e2e: add gcc

* E2E: install build-essential to get a working full gcc env

* :(

* e2e: support running from inside of docker

* fix lint error

* address review feedback

* Operator: fix bug where /-/ready and /-/healthy always returned 404 (#1252)

* operator: fix bug where /-/ready and /-/healthy always returned 404

controller-runtime must have at least one ready/healthy check for the endpoints to exist

* fix lint error, use healthz.Ping

* Make scraping-svc use the new `metrics:` key (#1259)

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* update prometheus dependency (#1260)

* corrected typo (#1265)

* Use RELEASE_TAG to choose between `:main` and `:latest` docker tags (#1264)

* Use RELEASE_TAG to choose between `:main` and `:latest` docker tags

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Use :main tag for images in smoke test

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Set IMAGE_BRANCH_TAG env var in drone and actions pipelines

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Remove quotes from Makefile variable

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Remove force_release action

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* prepare for v0.22.0 release (#1266)

* prepare for v0.22.0 release

* remove E2E pipeline

* Add basic testing framework for operator (#1268)

* remove dedicated go.mod for e2e/

* move e2e/k8s to pkg/util/k8s

* Migrate operator tests to pkg/util/k8s

* remove dedicated e2e tests

* allow skipping TestCluster in pkg/util/k8s

* remove e2e/

* fix bad merge

* fix order of make env args for windows

* actually declare referenced docker volume

* introduce pkg/util/subset for asserting subset of objects

* refactor operator so it's testable

* define basic integration test for operator

* fix lint errors

* fix invalid address in operator test config

* Update release-note.md (#1267)

* Set scrape User-Agent header during init (#1274)

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Upgrade to Go 1.17 (#1278)

* Upgrade to 1.17.6 in go.mod and Dockerfiles

* Update CHANGELOG.md to mention the update

* Update Go version in drone/actions pipelines

* Update go.mod, go.sum files via

* Re-sign drone.yml

* Remove leading newline causing drone build to fail

* Bump golangci-lint image to a version using Go 1.17

* Re-attempt to solve linter issue with new golangci-lint image

* Remove suffix of exclude rules

* Clean previous Go version before unpacking Go 1.17

* Also clean up previous Go versions in other steps

* fix typo (#1284)

* Use custom Go version in agent-operator Dockerfile (#1286)

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* pkg/operator: refactor resource hierarchy discovery (#1271)

* pkg/operator: refactor resource hierarchy discovery

This commit moves common logic related to discovering the resource
hierarchy to pkg/operator/hierarchy. This new package requires less
boilerplate, which the reconciler is updated to take advantage of.

* remove unused code

* test construction of resource hierarchy

* add missing build constraints

* small extra cleanup to use pointer package

* review feedback

* update agent-build-image for go 1.17 (#1287)

(also use a consistent base image tag instead of latest)

* Skip non-ready entries when listing instances (#1289)

* Skip non-ready instances in LoadInstances()

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>

* Add changelog entry

Co-authored-by: Robert Fratto <robertfratto@gmail.com>

* Fix panic in prom_sd_processor when address is empty (#1279)

* Fix panic in prom_sd_processor when address is empty

* Fix panic in prom_sd_processor when address is empty

* Fix docs

* Add test case

* Lint

* Move to unreleased

* Operator: generate proxy_url for remote_write (#1298)

* operator: generate proxy_url for remote_write

* fix weird indentation in test

Co-authored-by: Robert Fratto <robert.fratto@grafana.com>
Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com>
Co-authored-by: Mario <mariorvinas@gmail.com>
Co-authored-by: Robert Lankford <robert.lankford@grafana.com>
Co-authored-by: f11r <fiete.gruenter@rwth-aachen.de>
Co-authored-by: f11r <f11r@users.noreply.github.com>
Co-authored-by: Nick Pillitteri <56quarters@users.noreply.github.com>
Co-authored-by: Ryan Geyer <me@ryangeyer.com>
Co-authored-by: Juraci Paixão Kröhling <juraci.github@kroehling.de>
Co-authored-by: Robert Lankford <rlankfo@gmail.com>
Co-authored-by: Paschalis Tsilias <tpaschalis@users.noreply.github.com>
Co-authored-by: Patrick Koenig <pkoenig10@gmail.com>
Co-authored-by: DataPoints <langer.markus@gmail.com>
Co-authored-by: Alex <52292902+alexrudd2@users.noreply.github.com>
Co-authored-by: Robert Fratto <robertfratto@gmail.com>

* [RFC] Dynamic Documentation (#1308)

* Documentation and feature flag support. Part 1 of many.

* Fix linting

* Documentation

* More documentation

* MOAR documentation

* Update overall readme

* fix typo

* Update docs/configuration/dynamic-config.md

Co-authored-by: Robert Lankford <robert.lankford@grafana.com>

* fix typos and add additional comments

* Feedback from PR

* Allow overrides of documentation

Co-authored-by: Robert Lankford <robert.lankford@grafana.com>

* Code to support dynamic configuration. (#1360)

* Code to support dynamic configuration.

* Fix linting errors

* Fix issue with examples and add template parse

* Fix windows issues

* Simplify tests

* Respond to PR feedback

* Simplify tests and remove setting default

* Move to unexported configshim

* Export configshims members for testing

* Simplify singleton checking

* Add error around expand var

* sever -> server

* Better error code

* Fix error when unmarshalling yaml which allowed unexporting fields

* Switch to using require.noerror instead of assert.

* Split tests into two sections and remove redundant tests

* Verbiage cleanup and var renaming

* PR feedback

* PR feedback

* Move singleton check to the controller instead

* Cleanup the read file code to MUCH more compact code.

* Remove EOF

* PR feedback from session with rfratto, lots of changes to simplify the code

* Fix misc feedback from PR

* Dyn main merge (#1423)

* Update node_exporter dependency to v1.3.1 (#1228)

* Add node_exporter to depcheck

* update weaveworks/common dependency

* map current release flags and changed defaults

* documentation

* revert accidental checkin

* print out flags when node_exporter test fails to assist debugging

* oops, i introduced some flags from master by mistake

* Introduce experimental integrations revamp (#1198)

* [dev.multiple-integrations] Enable present integrations by default, deprecate enabled field (#1062)

* integrations: default to enabled by default

* document deprecation of enabled

* pkg/integrations: support *_configs field for integrations (#1130)

Creates the basic code to unmarshal integrations from a YAML field
called <integration name>_configs, which is a slice of that integration.

Note that this is NOT wired up to the integrations manager yet, and
trying to run the agent with more than one integration of the same type
will likely cause problems.

* [dev.multiple-integrations] Prototype new integrations subsystem (#1142)

* wip: prototype new integrations subsystem

* implement Controller with basic logic for Integration and UpdateIntegration

* Implement HTTPIntegration for Controller

* decouple controller and subsystem

* don't have controller implement integration

slightly less smelly now

* multiplexer integration

* rely on boilerplate for multiplexing for now

generics would be nice here

* remove multiplex_integration.go

Also a little code smelly. Instead of having integrations that run other
integrations, I'm going to fall back to having only one controller.

* introduce Subsystem, unexport Controller

start wiring up things to Subsystem

* introduce v2 agent integration to use for testing

* start wiring metrics integrations

* rename Options to Globals

call a spade a spade

* add subsystem options to globals

* remove dead code

* metricsutils: calculate self-scraping based on globals

* complete HTTP target API

* working example with agent integration

* appease the linter

* don't return an error when context to cancel an integration is closed

* once again i am asking the linter to forgive my typos

* fix bug where labels from individual targets were getting dropped at the API endpoint

* pkg/config: fix broken test

* finish unit tests for integrations v2 controller

* metricsutil/metricshandler_integration: make job name unique

Before this change, the job name would have collided when using multiple
instances of the same integration.

* ensure that global subsystem labels are injected into targets

* integrations/v2: Infer target hostname from SD API host (#1175)

* [dev.multiple-integrations] integrations/v2: allow shimming between v1 and v2 integrations. (#1179)

* integrations/v2: allow shimming between v1 and v2 integrations.

Shimming is done by changing how the integration registration works; a
new RegisterDynamic was added that allows for creating Configs at
runtime. Here be dragons; this should be removed whenever we no longer
have a need for it.

* fix lint

* pkg/integrations/v2: use "RegisterLegacy" instead of a generic mechanism

* fine, I won't add the deprecation notice if it will make the linter sad

* pkg/integrations: re-align (#1181)

This commit reverts 69ba2ddfa9483cc8ac6e010dd7abccd319580c80 in favor of
allowing the new subsystem to handle multiple instances of integrations.

This commit also removes the wal_truncate_frequency field from
integrations as it is the only field from old integrations that does not
have a current counterpart.

* [dev.multiple-integrations] Hide integrations/v2 behind a feature flag (#1185)

* feature flag wip

* dynamically switch between integrations v1 and v2

default to v1.

* pkg/integrations/versionselector to file in pkg/config

* pkg/config: fix defaults for Integrations

* pkg/config: use more generic way to unmarshal differently based on flag

* add missing godoc comment

* more comments

* switch to deferred unmarshaling

* remove unused Config field

* simplify completeUnmarshal

* do not perform lazy deferred unmarshaling

* enable cadvisor by default

* switch to using real feature flag

* fix postgres_exporter

* Merge main into dev.multiple-integrations (#1184)

* Fix typo (#1141)

* Traces: Improved pod association in PromSD processor (#1137)

* Improve k8s pod association

* Add tests

* Changelog

* typo

* Add prom_sd_pod_association

* Extend tests for pod associations

* Docs for pod association config

* Lint fixes

* Move to unreleased

* Add instrumentation recommendations

* Remove uncessary constants

* Improve tests

* remote config with http(s) provider (#1143)

* sample remote config code with http provider

* use t.TempDir() in unit test

* no need to clean up after T.TempDir()

* use NewClientFromConfig and make caller responsible for calling SetDirectory

* handle nil HTTPClientConfig

* remove blank identifier assignment

* pass basic auth command line flags for remote config

* address pr nits

* add expiremental flag

* set loader inline

* update changelog

* add remote config section in docs

* pr comment updates

* announce patch releases for cve-2021-41090 (#1152)

* Merge patch release to main (#1153)

* Add secret type to sensitive values

* Break out config tests to their own implementation. Also remove username has a sensitive value.

* Update changelog

* Fix failing test

* Scrub secrets when marshaling instance configs

* update for v0.21

* Updated changes from the merge.

* Remove changelog

* Scrub out receivers has ***receivers_scrubber***:null

* obscure etcd/consul credentials

* Update pkg/traces/config_test.go

Co-authored-by: Robert Fratto <robert.fratto@grafana.com>

* Update pkg/config/config.go

* go fmt

* Change to using custom object and return <secret>

* Fix bad merge

* [v0.21.2] toggle config endpoint (#19)

* disable /-/config endpoint by default

* disable scraping api get endpoint as well

* fix new test

* add test and rename flag

Co-authored-by: Robert Fratto <robertfratto@gmail.com>

* Update version to v0.21.2

* Update defaults.go

* fix /-/config endpoint

* also fix non-pointer config bug

* temporarily disable linting for release

* fix lint errors

Co-authored-by: Matt Durham <mattdurham@ppog.org>
Co-authored-by: Robert Lankford <robert.lankford@grafana.com>

* Fix POSTGRES_EXPORTER_DATA_SOURCE_NAME usage for postgres_exporter (#1162)

* Fix POSTGRES_EXPORTER_DATA_SOURCE_NAME usage for postgres_exporter

A recent change broke the usage of POSTGRES_EXPORTER_DATA_SOURCE_NAME for the postgres_exporter.
As the incorrect variable was checked in the if clause, it always raises an error.

* changelog: keep feature -> enhancement -> bugfix order

* postgres_exporter: add regression test

Co-authored-by: f11r <f11r@users.noreply.github.com>
Co-authored-by: Robert Fratto <robertfratto@gmail.com>

* Fix syntax error in Jsonnet logs helper method (#1174)

Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>

* cAdvisor Integration (#1081)

* Add cadvisor module

* Begin creating common config for cadvisor

* Don't export internal state

* Finish config options for cadvisor

* Set config options, and implement cAdvisor collectors

* Linting

* Buildflags for cadvisor only in linux

* I R LEArN Build Tags

* Don't zero value the zero value

* Offload sketchy global var manipulation to the integrations Run func

* Remove unused collectors

* Lint

* Create generic stub integration and use it for cadvisor

* Lint

* Final refactor of cAdvisor config for unsupported platforms. Pared down stub integrations.

* L…
  • Loading branch information
1 parent 5bbc8cb commit 0fcdbb8
Show file tree
Hide file tree
Showing 70 changed files with 4,249 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
name: Test
strategy:
matrix:
platform: [macos-latest, windows-latest]
platform: [macos-latest, windows-2019]
runs-on: ${{ matrix.platform }}
steps:
- name: Set up Go 1.17
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@

- [ENHANCEMENT] Upgrade to loki v2.4.2. The following metrics will now be prefixed with `agent_dskit_` instead of `cortex_`: `cortex_kv_request_duration_seconds`, `cortex_member_consul_heartbeats_total`, `cortex_member_ring_tokens_owned`, `cortex_member_ring_tokens_to_own`, `cortex_ring_member_ownership_percent`, `cortex_ring_members`, `cortex_ring_oldest_member_timestamp`, `cortex_ring_tokens_owned`, `cortex_ring_tokens_total`. (@rlankfo)

- [ENHANCEMENT] Introduce EXPERIMENTAL support for dynamic configuration. (@mattdurham)

- [FEATURE] Added config read API support to GrafanaAgent Custom Resource Definition.

- [FEATURE] Added consulagent_sd to target discovery. (@chuckyz)

- [BUGFIX] Ensure singleton integrations are honored in v2 integrations (@mattdurham)

# v0.23.0 (2022-01-13)

- [ENHANCEMENT] Go 1.17 is now used for all builds of the Agent. (@tpaschalis)
Expand Down
37 changes: 37 additions & 0 deletions cmd/agentctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"strings"
"time"

"gopkg.in/yaml.v2"

// Adds version information
_ "github.com/grafana/agent/pkg/build"
"github.com/grafana/agent/pkg/client/grafanacloud"
Expand Down Expand Up @@ -60,6 +62,7 @@ func main() {
samplesCmd(),
operatorDetachCmd(),
cloudConfigCmd(),
templateDryRunCmd(),
)

_ = cmd.Execute()
Expand Down Expand Up @@ -474,6 +477,40 @@ config that may be used with this agent.`,
return cmd
}

func templateDryRunCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "template-parse [directory]",
Short: "dry run dynamic configuration",
Long: `This will load the dynamic configuration, load configs, run templates and then output the full config as yaml`,
Args: cobra.ExactArgs(1),

RunE: func(_ *cobra.Command, args []string) error {
cmf, err := config.NewDynamicLoader()
if err != nil {
return err
}
c := &config.Config{}
err = cmf.LoadConfigByPath(args[0])
if err != nil {
return err
}
err = cmf.ProcessConfigs(c)
if err != nil {
return fmt.Errorf("error processing config templates %s", err)
}

outBytes, err := yaml.Marshal(c)
if err != nil {
return err
}
fmt.Println(string(outBytes))
return nil
},
}

return cmd
}

func must(err error) {
if err != nil {
panic(err)
Expand Down
127 changes: 127 additions & 0 deletions docs/user/configuration/dynamic-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Dynamic Configuration - Experimental

**This is experimental and subject to change at anytime, feedback is much appreciated. This is a feature that MAY NOT make it production.**

Dynamic Configuration is the combination of two things:

* Loading from multiple files
* Using templates and datasources

Both of these make heavy use of the excellent [gomplate](https://github.com/hairyhenderson/gomplate). The goal is
that as the configuration grows that it can be split it up into smaller segments to allow better readability and handling.
The configurations cannot be patched in any order and instead are allowed at several levels.

The second goal is to allow the use of templating, functions for [gomplate doc](https://docs.gomplate.ca/) go into detail
on what functions are available.

## Configuration

Location of the dynamic configuration is used via the feature flag `dynamic-config`, then it will use `-config.dynamic-config-path` to
load the configuration for dynamic configuration.

```yaml
# Sources to pull template values
datasources:
[- <sources_config>]

# Locations to use searching for templates, the system does NOT look into subdirectories. Follows gomplate schema
# from [gomplate datasources](https://docs.gomplate.ca/datasources/). File and S3/GCP templates are currently supported
template_paths:
[ - string ]

# Filters allow you to override the default naming convention

agent_filter: string # defaults to agent-*.yml
server_filter: string # defaults to server-*.yml
metrics_filter: string # defaults to metrics-*.yml
metrics_instance_filter: string # defaults to metrics_instances-*.yml
integrations_filter: string # defaults to integrations-*.yml
logs_filter: string # defaults to logs-*.yml
traces_filter: string # defaults to traces-*.yml
```
### sources_config
```yaml
# Name of the source to use when templating
name: string

# Path to datasource using schema from [gomplate datasources](https://docs.gomplate.ca/datasources/)
url: string

```
## Templates
Note when adding a template you MUST NOT add the type as the top level yaml field. For instance if using traces:
Incorrect
```yaml
traces:
configs:
- name: default
automatic_logging:
backend: loki
loki_name: default
spans: true
```
Correct
```yaml
configs:
- name: default
automatic_logging:
backend: loki
loki_name: default
spans: true
```
Configurations are loaded in the order as they are listed below.
### Agent
Agent template is the standard agent configuration file in its entirety. The default filter is `agent-*.yml`. Only
one file is supported. This is processed first then any subsequent configurations found REPLACE the values here, it is
not additive.

Reference {{< relref "./" >}})

### Server

The default filter is `server-*.yml`, only ONE server file is supported.

Reference {{< relref "./server-config.md" >}})


### Metrics

The default filter is `metrics-*.yml`, only ONE metrics file is supported.

Reference {{< relref "./metrics-config.md" >}})

### Metric Instances

The default filter is `metrics_instances-*.yml`. Any metric instances are appended to the instances defined in Metrics above. Any number of metric instance files are supporter.

Reference {{< relref "./metrics-config.md#metrics_instance_config" >}}) in the metrics instance


### Integrations

The default filter is `integrations-*.yml`, these support more than one file, and multiple integrations can be defined in a file. Do not assume any order of loading for integrations. For any integration that is a singleton, loading multiple of those will result in an error.

Reference {{< relref "./integrations/" >}})

### Traces

The default filter is `traces-*.yml`. This supports ONE file.

Reference {{< relref "./traces-config.md" >}})

### Logs

The default filter is `logs-*.yml`. This supports ONE file.

Reference {{< relref "./logs-config.md" >}})
64 changes: 64 additions & 0 deletions docs/user/cookbook/dynamic-configuration/01_Basics/01_Structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 01 Structure

Dynamic Configuration uses a series of files to load templates. This example will show how they all combine together. Running the below command will combine all the templates into the final.yml. Any failure while loading the config will revert to the original config, or if this is the initial load Grafana Agent will quit.

`docker run -v ${PWD}/:/etc/grafana grafana/agentctl:latest template-parse file:///etc/grafana/01_config.yml`

## Dynamic Configuration

[config.yml](01_config.yml)

```yaml
template_paths:
- "file:///etc/grafana/01_assets"
```
Tells the Grafana Agent where to load files from. It is important to note that dynamic configuration does NOT traverse directories. It will look at the directory specified only, if you need more directories then add them to the `template_paths` array. NOTE, if no protocol specified ie `file://` above, then file access will be assumed. `file:///etc/grafana/01_assets` is equivalent to `//etc/grafana/01_assets`

## Agent

Dynamic Configuration will find the first file matching pattern `agent-*.yml` and load that as the base. You can only have one agent template. If multiple matching templates are found then the configuration will fail to load.

[agent-1.yml](01_assets/agent-1.yml)

```yaml
server:
http_listen_port: 12345
log_level: debug
metrics:
wal_directory: /tmp/grafana-agent-normal
global:
scrape_interval: 60s
remote_write:
- url: https://prometheus-us-central1.grafana.net/api/prom/push
basic_auth:
username: 12345
password: secretpassword
integrations:
node_exporter:
enabled: true
agent:
enabled: true
```

## Server

Dynamic configuration will find the first file matching pattern `server-*.yml` and replace the `Server` config block in
the Agent Configuration. Note that you do NOT include the `server:` tag, dynamic configuration knows by the name that it
is a configuration block.

You can only have 1 server template.

[server-1.yml](01_assets/server-1.yml)


```yaml
http_listen_port: 12345
log_level: info
```

## Final

[final.yml](01_assets/final.yml)

In the above example the `log_level: debug` block will be replaced with `log_level: info` from the server-1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
server:
http_listen_port: 12345
log_level: debug
metrics:
wal_directory: /tmp/grafana-agent-normal
global:
scrape_interval: 60s
remote_write:
- url: https://prometheus-us-central1.grafana.net/api/prom/push
basic_auth:
username: 12345
password: secretpassword
integrations:
node_exporter:
autoscrape:
enable: true
agent:
autoscrape:
enable: true
Loading

0 comments on commit 0fcdbb8

Please sign in to comment.