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

[Loki] Whitelisting automatic Kubernetes stream labels #3131

Closed
vladimirfx opened this issue Feb 25, 2021 · 12 comments
Closed

[Loki] Whitelisting automatic Kubernetes stream labels #3131

vladimirfx opened this issue Feb 25, 2021 · 12 comments

Comments

@vladimirfx
Copy link

Is your feature request related to a problem? Please describe.

Loki strongly recommends using stable label values for stream labels. But automatic Kubernetes labels nearly always include some runtime hashes such as controller_revision_hash, pod_template_hash etc. That makes using of k8s auto labels fatal for Loki instance in long run because of infinitely growing label values.

Describe the solution you'd like
It would be nice to have functionality similar to record_modifier filter to include/exclude/whitelist stream labels.

@edsiper
Copy link
Member

edsiper commented Feb 25, 2021

@vladimirfx what about the option remove_keys ?, it should do the job.

@edsiper edsiper self-assigned this Feb 25, 2021
@edsiper edsiper added the waiting-for-user Waiting for more information, tests or requested changes label Feb 25, 2021
@vladimirfx
Copy link
Author

@vladimirfx what about the option remove_keys ?, it should do the job.

Do you mean record_modifier filter? We are trying to implement this but this issue not about lossy modification of record but about filtering of Loki stream labels. Loki is very sensitive to stream labels especially in context of chunks ordering.

@edsiper
Copy link
Member

edsiper commented Feb 25, 2021

Loki output plugin has a configuration property called remove_keys, e.g:

[OUTPUT]
    name        loki
    match       *
    remove_keys $key1, $key2, $key3['sub']['aaa']
    ...

@vladimirfx
Copy link
Author

I see this in code but not in docs. Thanks I've try it!
This removes key from record or from stream labels?

@vladimirfx
Copy link
Author

Unfortunately remove_keys not remove nested keys. Neither works:

Remove_keys $kubernetes['labels']['controller-revision-hash']

Remove_keys $kubernetes['labels']['controller_revision_hash']

Remove_keys kubernetes['labels']['controller_revision_hash']

Remove_keys kubernetes.labels.controller_revision_hash

Record:

{
"log":"2021-02-25T17:04:05.843785213Z stdout F 2021-02-25 17:04:05,838 INFO: no action.  i am the leader with the lock",
"kubernetes":{
"pod_name":"search-city-db-0",
"namespace_name":"default",
"pod_id":"67df6c12-053a-4268-b63b-fa00b304af25",
"labels":{
"application":"postgresql",
"cluster-name":"search-city-db",
"controller-revision-hash":"search-city-db-56bfc889bb",
"spilo-role":"master","statefulset.kubernetes.io/pod-name":"search-city-db-0"},
"annotations":{
"status":"{\"conn_url\":\"postgres://10.42.1.185:5432/postgres\",\"api_url\":\"http://10.42.1.185:8008/patroni\",\"state\":\"running\",\"role\":\"master\",\"version\":\"2.0.1\",\"xlog_location\":2415919104,\"timeline\":112}"},
"container_name":"postgres",
"docker_id":"c22b8b4bb4258f5a54aa7573aa9ac4bd055d47bf5d7d03c1c428f356d7c6acdf",
"container_hash":"registry.opensource.zalan.do/acid/spilo-13@sha256:843c659bc9c430caa81e1af1fb23c7287e0acb3c9c80288f656fcf2c82b49cc2",
"container_image":"registry.opensource.zalan.do/acid/spilo-13:2.0-p4"
}
}

@edsiper
Copy link
Member

edsiper commented Feb 25, 2021

please share your full configuration.

@edsiper edsiper added troubleshooting and removed waiting-for-user Waiting for more information, tests or requested changes labels Feb 25, 2021
@vladimirfx
Copy link
Author

flbconf.zip

@vladimirfx
Copy link
Author

vladimirfx commented Feb 27, 2021

Anyway if Remove_keys will work this particular issue is not about destructive change of record but about stream labels.

What do you think about Whitelist_label for effective stream labels list?

Whitelist_label app_kubernetes_io_name
Whitelist_label app_kubernetes_io_part_of
Whitelist_label namespace_name
Whitelist_label pod_name

If you ok I've try to implement it.

@vladimirfx
Copy link
Author

Related Loki/Promtail ticket - grafana/loki#3390

@vladimirfx vladimirfx changed the title [Loki] Exclude/include filter for automatic Kubernetes labels [Loki] Whitelisting automatic Kubernetes stream labels Mar 1, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Apr 1, 2021

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Apr 1, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Apr 7, 2021

This issue was closed because it has been stalled for 5 days with no activity.

@github-actions github-actions bot closed this as completed Apr 7, 2021
@vladimirfx
Copy link
Author

Issue closed because no one can tell does this proposal makes sense or not. Not to implement it but just ok or nok.
That sad but the project looks semi-dead...

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

No branches or pull requests

2 participants