Skip to content
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

Feat: Allow filename as source to add custom label from __path__ #1013

Closed
wants to merge 1 commit into from

Conversation

adityacs
Copy link
Contributor

what this PR does?

Allow filename as source to add custom label from path

Which issue(s) this PR fixes:
Fixes #775

@cyriltovena @sandlis I am not sure if this change is a good way to handle the issue described in #775 but I couldn't think of anything better than this. Let me know your thoughts.

@slim-bean
Copy link
Collaborator

I think the approach I would rather take for this is to add label as another key along side source in the regex stage such that you could use any label as an input to the stage

@adityacs
Copy link
Contributor Author

adityacs commented Sep 14, 2019

@slim-bean Makes sense. Have made the changes. Kindly review. If this is fine, I will fix tests and modify the docs.

@cyriltovena
Copy link
Contributor

Can you check if the full filename is part of labels coming in ?

@adityacs
Copy link
Contributor Author

adityacs commented Sep 16, 2019

@cyriltovena I am just capturing like this sourceInput := string(labels[model.LabelName(*r.cfg.Source.Label)]). So, input label can be anything .Also, filename would be anyway expanded by promtail before pipeline stage begins

@cyriltovena
Copy link
Contributor

Yeah I'm not too keen on breaking the configuration right now. @slim-bean should we just merge extracted with labels coming in ?

@adityacs
Copy link
Contributor Author

adityacs commented Sep 16, 2019

@cyriltovena

Yeah I'm not too keen on breaking the configuration right now

Makes sense.

Any approach is fine to me. Let know, I will push my changes accordingly.

@slim-bean
Copy link
Collaborator

Yeah I'm going to have to agree on not wanting to make a breaking config change.

I am debating if there are any disadvantages to having source look both at labels and the extractedMap.

The most obvious would be naming collisions between data in the extracted map and labels, and which takes precedence.

I am thinking because such collisions are easily controlled by the person creating the config, it would make sense if source could pull from both labels and extractedMap, that the value in the extractedMap would take precedence.

Or put another way, source would check for a matching label if nothing was found in the extractedMap.

I am going to sleep on it and hopefully not change my mind tomorrow, but I'm thinking right now lets just keep source the way it is in config, but in the implementation first look in the extractedMap and if nothing is found, look for a label.

@adityacs
Copy link
Contributor Author

@slim-bean

Or put another way, source would check for a matching label if nothing was found in the extractedMap.

have made changes accordingly. Kindly review.

@cyriltovena
Copy link
Contributor

Can you update the documentation ? or give a hint about this new way of working for the source parameter ?

Thanks !

@adityacs
Copy link
Contributor Author

adityacs commented Oct 7, 2019

Closing this PR in favour of #1122

@adityacs adityacs closed this Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Promtail: Cant get the value of filename in relabel_configs
3 participants