Skip to content

feat(lambda-promtail): Improve relabel configuration parsing and testing #16100

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

Merged
merged 2 commits into from
Feb 5, 2025

Conversation

cyriltovena
Copy link
Contributor

This is required because original relabeling config only support yaml but the lambda promtail config is in json

This change introduces a more robust way of parsing and handling relabel configurations in the lambda-promtail tool. Key improvements include:

  • Added a new relabel.go with custom JSON-friendly RelabelConfig
  • Implemented conversion to Prometheus relabel configs
  • Added comprehensive test suite for relabel config parsing
  • Simplified environment variable handling in main.go
This is required because original relabeling config only support yaml but the lambda promtail config is in json

This change introduces a more robust way of parsing and handling relabel configurations in the lambda-promtail tool. Key improvements include:
- Added a new `relabel.go` with custom JSON-friendly RelabelConfig
- Implemented conversion to Prometheus relabel configs
- Added comprehensive test suite for relabel config parsing
- Simplified environment variable handling in main.go
@cyriltovena cyriltovena requested a review from a team as a code owner February 5, 2025 08:54
@cyriltovena cyriltovena enabled auto-merge (squash) February 5, 2025 08:57
Copy link
Contributor

@chaudum chaudum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

Comment on lines 32 to 33
// UnmarshalYAML implements the yaml.Unmarshaler interface.
func (rc *RelabelConfig) UnmarshalJSON(data []byte) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docstring does not match the function name

Suggested change
// UnmarshalYAML implements the yaml.Unmarshaler interface.
func (rc *RelabelConfig) UnmarshalJSON(data []byte) error {
// UnmarshalJSON implements the json.Unmarshaler interface.
func (rc *RelabelConfig) UnmarshalJSON(data []byte) error {
type RelabelConfig struct {
// A list of labels from which values are taken and concatenated
// with the configured separator in order.
SourceLabels []string `yaml:"source_labels,flow,omitempty" json:"source_labels,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we omit the yaml: tag, since it is not supported?

@cyriltovena
Copy link
Contributor Author

Confirmed this fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 participants