-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Prometheus Remote Write Exporter supporting Cortex - Factory and Config #1524
Conversation
…for service package
Please fix lint errors |
Hi @bogdandrutu, will do! I will also add that the PR #1525 actually contains the total codebase (everything in this PR + logic for the exporter) Yang and I worked on, so there is no need to pull this codebase, should the other PR gets merged. |
@danielbang907 would prefer to merge this separated, easier to review |
Namespace string `mapstructure:"namespace"` | ||
|
||
// Optional headers configuration for authorization and security/extra metadata | ||
Headers map[string]string `mapstructure:"headers"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be added to HTTPClientSettings
// Optional headers configuration for authorization and security/extra metadata | ||
Headers map[string]string `mapstructure:"headers"` | ||
|
||
HTTPClientSettings confighttp.HTTPClientSettings `mapstructure:"http_setting"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most likely this can be squashed without a name
exporterhelper.WithMetrics(createMetricsExporter)) | ||
} | ||
|
||
// Instantiates a pseudo-Cortex Exporter that adheres to the component MetricsExporter interface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments in golang should start with the func name:
"// createMetricsExporter instantiates ... "
|
||
// Instantiates the default version of a Remote Write Exporter config struct to | ||
// be used by the factory to build Exporter instances | ||
func createDefaultConfig() configmodels.Exporter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for func names
//Tests whether or not the default Exporter factory can instantiate a properly interfaced Exporter with default conditions | ||
func TestCreateDefaultConfig(t *testing.T) { | ||
factory := NewFactory() | ||
cfg := factory.CreateDefaultConfig() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can call directly createDefaultConfig
|
||
//Tests whether or not a correct Metrics Exporter from the default Config parameters | ||
func TestCreateMetricsExporter(t *testing.T) { | ||
factory := NewFactory() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same no need to have a factory
File structure: | ||
|
||
- `cortex.go`: exporter implementation. Converts and sends OTLP metrics | ||
|
||
- `helper.go`: helper functions that cortex.go uses. Performs tasks such as sanitizing label and generating signature string | ||
|
||
- `config.go`: configuration struct of the exporter | ||
|
||
- `factory.go`: initialization methods for creating default configuration and the exporter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will soon get outdated, recommend to not have it here.
Closing this PR as @huyan0 is filing one that addresses the current comments and CI checks. |
* fix: grpc reconnection fixed * chore: changelog update * fix: grpc reconnection issue - red test * fix: grpc reconnection open-telemetry#1524 * fix: grpc reconnection issue cleanup
Description:
This PR implements the config, config YAML, and factory structs, the prwExporter struct. It also includes the README.md for a sample configuration to run this Prometheus remote-write exporter. The config and factory structs are fully compatible with the Collector component interfaces.
Link to tracking Issue:
#1150
Related issues are:
Metrics aggregation proposal: #1422
Prometheus exporter not functional: #1255
Related spec discussion: #731
Testing:
The unit tests coverage is currently at 86.2% for this pull request. However combining this PR with other related PRs increases the coverage to 92.1%.
Documentation:
cc: @huyan0 @danielbang907 @alolita @markcartertm @sonofachamp @morigs
Request for review: @jmacd @bogdandrutu @annanay25 @gouthamve @open-telemetry/collector-approvers @open-telemetry/collector-maintainers