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

chore: Fix promtail local config #14259

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LashaJini
Copy link

@LashaJini LashaJini commented Sep 25, 2024

What this PR does / why we need it:

👋, According to Build and run from source promtail should start without issues when only config file is passed (without passing any additional flags). However, because of the missing fields in the promtail-local-config.yaml file, it fails.

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • For Helm chart changes bump the Helm chart version in production/helm/loki/Chart.yaml and update production/helm/loki/CHANGELOG.md and production/helm/loki/README.md. Example PR
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

@CLAassistant
Copy link

CLAassistant commented Sep 25, 2024

CLA assistant check
All committers have signed the CLA.

@@ -1,9 +1,13 @@
server:
http_listen_port: 9080
grpc_listen_port: 0
log_level: debug
Copy link
Author

Choose a reason for hiding this comment

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


positions:
filename: /tmp/positions.yaml
sync_period: 10s
Copy link
Author

Choose a reason for hiding this comment

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


positions:
filename: /tmp/positions.yaml
sync_period: 10s
target_config:
sync_period: 10s
Copy link
Author

Choose a reason for hiding this comment

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

@LashaJini LashaJini force-pushed the add-missing-fields-in-promtail-local-config branch 2 times, most recently from 9d04b38 to ea3cc5f Compare September 25, 2024 13:02
@LashaJini LashaJini marked this pull request as ready for review September 25, 2024 14:41
@LashaJini LashaJini requested a review from a team as a code owner September 25, 2024 14:42
Copy link
Collaborator

@trevorwhitney trevorwhitney left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. Can you share the error you recieved? I was able to start up without problem using this config locally. Some of the configs you're setting we have defaults for, for example log level

@LashaJini
Copy link
Author

LashaJini commented Oct 3, 2024

Thanks for the contribution. Can you share the error you recieved? I was able to start up without problem using this config locally. Some of the configs you're setting we have defaults for, for example log level

with current config:
Screenshot from 2024-10-03 22-04-04

After passing the log.level flag:
Screenshot from 2024-10-03 12-46-16

According to docs, I just assumed that passing the config file only, should be sufficient to start promtail.

@trevorwhitney
Copy link
Collaborator

you're using two different config paths in that example. cmd/promtail/promtail-local-config.yaml in the first screenshot should be clients/cmd/promtail/promtail-local-config.yaml

@LashaJini
Copy link
Author

LashaJini commented Oct 3, 2024

you're using two different config paths in that example. cmd/promtail/promtail-local-config.yaml in the first screenshot should be clients/cmd/promtail/promtail-local-config.yaml

My bad, wrong screenshot. I've added the correct one 👍

There is no promtail config in cmd directory, even though the docs states so.

@trevorwhitney
Copy link
Collaborator

Got it, thanks for the update, I was able to re-create. Thanks for offering a fix, but I think we should fix the code instead of just adding a band-aid to the config file. I spent a little time looking at this and I'm not sure why the level config is empty when we check it. We are definitely calling .RegisterFlags on it, which sets the level to info, so this seems like a regression to me.

@LashaJini
Copy link
Author

Let me know if we should close the PR and open a new one. Meanwhile I can also look into it later 👍

@cstyan
Copy link
Contributor

cstyan commented Oct 4, 2024

Got it, thanks for the update, I was able to re-create. Thanks for offering a fix, but I think we should fix the code instead of just adding a band-aid to the config file. I spent a little time looking at this and I'm not sure why the level config is empty when we check it. We are definitely calling .RegisterFlags on it, which sets the level to info, so this seems like a regression to me.

I was thinking the same recently, I think maybe https://github.com/grafana/loki/pull/13719/files is the cause of this as it might have changed how default values for some config structs are applied.

@LashaJini
Copy link
Author

LashaJini commented Oct 4, 2024

Got it, thanks for the update, I was able to re-create. Thanks for offering a fix, but I think we should fix the code instead of just adding a band-aid to the config file. I spent a little time looking at this and I'm not sure why the level config is empty when we check it. We are definitely calling .RegisterFlags on it, which sets the level to info, so this seems like a regression to me.

I was thinking the same recently, I think maybe https://github.com/grafana/loki/pull/13719/files is the cause of this as it might have changed how default values for some config structs are applied.

Just tested it. Commented out the whole UnmarshalYAML method, rebuilt promtail and works without any modification to the original config file 👍. but why 😃

@trevorwhitney
Copy link
Collaborator

@fgouteroux looks like #13719 may have introduced a regression here, thoughts on a fix?

@fgouteroux
Copy link
Contributor

@fgouteroux looks like #13719 may have introduced a regression here, thoughts on a fix?

I think its is caused by: https://github.com/grafana/loki/blob/main/clients/pkg/promtail/config/config.go#L45 this is why there is default config var in https://github.com/prometheus/prometheus/blob/main/config/config.go#L146.

That explain why any default value from flag are not kept after UnmarshalYAML func.

@cstyan
Copy link
Contributor

cstyan commented Oct 7, 2024

@fgouteroux looks like #13719 may have introduced a regression here, thoughts on a fix?

I think its is caused by: https://github.com/grafana/loki/blob/main/clients/pkg/promtail/config/config.go#L45 this is why there is default config var in https://github.com/prometheus/prometheus/blob/main/config/config.go#L146.

That explain why any default value from flag are not kept after UnmarshalYAML func.

The second link you gave was to Prometheus code, so it's not relevant to the issue reported here. For Loki and Promtail we use default values via our CLI arguments, so there were default values that were being overwritten by the UnmarshalYAML function. #14408 fixes the proble, so this PR shouldn't be necessary anymore.

@LashaJini let us know if you still see any similar problems.

@fgouteroux
Copy link
Contributor

oh I miss this line 😂

@LashaJini LashaJini force-pushed the add-missing-fields-in-promtail-local-config branch from ea3cc5f to 6aa401e Compare October 7, 2024 17:11
@LashaJini
Copy link
Author

@fgouteroux looks like #13719 may have introduced a regression here, thoughts on a fix?

I think its is caused by: https://github.com/grafana/loki/blob/main/clients/pkg/promtail/config/config.go#L45 this is why there is default config var in https://github.com/prometheus/prometheus/blob/main/config/config.go#L146.
That explain why any default value from flag are not kept after UnmarshalYAML func.

The second link you gave was to Prometheus code, so it's not relevant to the issue reported here. For Loki and Promtail we use default values via our CLI arguments, so there were default values that were being overwritten by the UnmarshalYAML function. #14408 fixes the proble, so this PR shouldn't be necessary anymore.

@LashaJini let us know if you still see any similar problems.

Awesome. Then it's just a matter of doc update. We can merge now 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants