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

Use 'level' instead of 'severity' #17

Open
MartijnVanAndel opened this issue Feb 15, 2021 · 4 comments
Open

Use 'level' instead of 'severity' #17

MartijnVanAndel opened this issue Feb 15, 2021 · 4 comments

Comments

@MartijnVanAndel
Copy link

Loki and Grafana use level as label to show the logging severity/verbose/levelname. It would be useful to replace the current severity label with level, as all queries and visualizations in Grafana would automatically pick up the log level.
I can create a pull request if you like, but let me know if the current has a special purpose.

@Apollo3zehn
Copy link

That would be a very simple and useful change.

Grafana Loki output with and without level=error:
image

@Apollo3zehn
Copy link

Apollo3zehn commented Aug 11, 2021

It seems the level tag can be easily changed with the following code:

import logging

from logging_loki import LokiHandler, emitter

emitter.LokiEmitter.level_tag = "level"

handler = LokiHandler(
    url="<url>", 
    tags={"app": "<appname>"},
    version="1",
)

logger = logging.getLogger("<loggername>")
logger.addHandler(handler)
logger.error(
    "Something happened", 
    extra={"tags": {"service": "my-service"}},
)

@edeno1
Copy link

edeno1 commented Jul 11, 2022

Hi, the logger only supports error I can send logs to Loki but I perform logger.info he does not write it to Loki

@Jacob-EWE
Copy link

Hi @edeno1

If it is still a problem for you, this article solves the problem:

In short, you need to set the default level to a lower level, for example to DEBUG. This is done with logger.setLevel(logging.DEBUG)

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

No branches or pull requests

4 participants