-
-
Notifications
You must be signed in to change notification settings - Fork 233
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
Grafana dashboard not displaying any logs in loki panels #761
Comments
You need to set |
But if you do that, you lose the visibility of which host each log message came from. If your prometheus job for scraping metrics is called "incus" then you'll have to set Whereas for metrics, instance="XXX" tells you the host which is scraped, and therefore which host the container is running on. This is true even for clusters according to the documentation:
It would be strange if metrics had instance="nuc1", instance="nuc2", instance="nuc3" but logs all had instance="incus". |
You don't, the |
I get I also get |
Yeah, those two fields seem wrong in non-clustered case, both should default to your hostname in non-clustered cases and |
From your suggested changes above, I'll be taking the The Also |
Oops, I had hoped it would do something sensible like empty string or However, apparently there is a "custom all value", which I found via here and here.
OK, fair enough - although if "All" did match |
Closes lxc#761 Signed-off-by: Stéphane Graber <[email protected]>
Closes canonical#13165 and lxc/incus#761 Signed-off-by: Stéphane Graber <[email protected]> (cherry picked from commit 9d31814a93669e38d6b6a2a8215175f546f582d1) Signed-off-by: Simon Deziel <[email protected]> License: Apache-2.0
Closes canonical#13165 and lxc/incus#761 Signed-off-by: Stéphane Graber <[email protected]> (cherry picked from commit 9d31814a93669e38d6b6a2a8215175f546f582d1) Signed-off-by: Simon Deziel <[email protected]> License: Apache-2.0
Closes canonical#13165 and lxc/incus#761 Signed-off-by: Stéphane Graber <[email protected]> (cherry picked from commit 9d31814a93669e38d6b6a2a8215175f546f582d1) Signed-off-by: Simon Deziel <[email protected]> License: Apache-2.0
Closes #761 Signed-off-by: Stéphane Graber <[email protected]>
Closes canonical#13165 and lxc/incus#761 Signed-off-by: Stéphane Graber <[email protected]> (cherry picked from commit 9d31814a93669e38d6b6a2a8215175f546f582d1) Signed-off-by: Simon Deziel <[email protected]> License: Apache-2.0
Required information
Issue description
This is an issue with the grafana dashboard, https://grafana.com/grafana/dashboards/19727-incus/
Metrics display is working fine, but the loki panels at the bottom are empty. This is because the LogQL queries are wrong.
They have
{app="incus",type="lifecycle",instance="$job"}
for the first panel, and{app="incus",type="logging",instance="$job"}
for the second.However the "instance" label in logs don't contain the job name or the container name. Also, the
$job
variable in Grafana is the prometheus scrape job name, and has nothing to do with loki logs.Here are some example logs:
Notice how some logs have the name of the container as a label (
name="netbox4"
), but some other logs relating to this container don't. They may have it buried in the logfmt data though, e.g.context-instance="nfsen"
orsource="/1.0/instances/nfsen"
. If you filter logs by container, you still want to see those logs.I propose that at simplest, the queries need to change to:
The vertical bar inside the regexp is because the "name" and "project" labels may be missing (even for logs specific to one container), so we must allow through lines where this label is missing.
However, that will also show logs for other containers, when those logs have no name or project label. A bit of additional filtering can ensure that the container name appears somewhere in the log line:
This now works as expected:
However, if one container name is a prefix of another container name, or two projects have containers with the same name, it may show some logs for another container. A more sophisticated filter is possible:
This assumes that every log relating to container X either has label
name="X"
or the log message containscontext_instance="X"
. (Note that hyphens in logfmt attributes are converted to underscores, so that they become valid LogQL label names)This is true for the logs shown above. In fact, in these examples the lifecycle logs all have
name="X",project="Y"
and the event logs havecontext_instance="X",context_project="Y"
, so the queries can simplify to:I've tried this and it works for me. However I'm not sure if those conditions are true in general for all possible logs from incus. It could be argued it's hard-coding too much info about the log attributes.
Steps to reproduce
incus config set loki.api.url=http://loki.example.net:3100
Cross-reference
Issue appears to be inherited from lxd dashboard, raised previously: canonical/lxd#13165
The text was updated successfully, but these errors were encountered: