-
Notifications
You must be signed in to change notification settings - Fork 61
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
Tracing not showing in grafana #29
Comments
Hey @titogarrido, have you configured the grafana |
Hi @fullonic ! Yes, it should be connect... Is there a way to debug what python-logging-loki is sending to Loki? |
@app.on_event("startup")
async def startup():
Instrumentator().instrument(app).expose(app)
LoggingInstrumentor().instrument(set_logging_format=True)
emitter.LokiEmitter.level_tag = "level"
lokiHandler = LokiHandler(
url="http://ipadpi.local:3100/loki/api/v1/push",
tags={"application": "backend"},
version="1",
)
FILE_FORMAT = logging.Formatter('%(asctime)s %(levelname)s [%(name)s] [%(filename)s:%(lineno)d] [trace_id=%(otelTraceID)s span_id=%(otelSpanID)s resource.service.name=%(otelServiceName)s] - %(message)s')
LOKI_FORMAT = logging.Formatter('%(asctime)s %(levelname)s %(name)s %(filename)s:%(lineno)d trace_id=%(otelTraceID)s span_id=%(otelSpanID)s resource.service.name=%(otelServiceName)s %(message)s')
fileHandler = logging.FileHandler("backend.log")
fileHandler.setFormatter(FILE_FORMAT)
lokiHandler.setFormatter(LOKI_FORMAT)
logger = logging.getLogger(__name__)
logger.addHandler(lokiHandler)
logger.setLevel(logging.DEBUG)
logger.addHandler(fileHandler) Ok, that works, I have to add the format to loki handler. |
I had this same issue. When viewing logs using Grafana's "Logs visualizer" documented here, the label browser shows labels that were definitely unique to the logs I sent, but no entries appear when I run the LogQL query. (query returned 0 results errors)/ Once I changed the python formatter to Note the early messages didn't include the header, and show up in grey. Recent messages include The need for a formatter should be mentioned in the main README! |
Hi Folks,
I am trying to use Loki + Tempo but when I check my logs in Loki the trace_id and span_id are missing.
Code related to logging:
The result in loki is:
and I am running my uvicorn using:
opentelemetry-instrument uvicorn main:app
What am I missing here?
The text was updated successfully, but these errors were encountered: