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

logs both in Grafana and through Jenkins config - breaks displayed logs (colors?) #918

Closed
ArieLevs opened this issue Aug 12, 2024 · 6 comments
Labels
question Further information is requested

Comments

@ArieLevs
Copy link

Jenkins and plugins versions report

Environment
plugin version 3.1320.v2eededb_d909e

What Operating System are you using (both controller, and any agents involved in the problem)?

Jenkins 2.452.2
Jenkins in kubernetes, default agent is jenkins/inbound-agent:jdk17

Reproduction steps

  1. follow Storing Jenkins Pipeline Logs in Loki
  2. configure the Store pipeline logs In Loki and visualize logs both in Grafana and through Jenkins option
  3. logs are shown in Jenkins UI and in Grafana, which is OK
  4. logs are missing colors, links are not clickable (from Jenkins UI), seems that anything that has special characters no longer appears in logs

Expected Results

logs should keep appearing as usual both in Grafana and Jenkins UI

Actual Results

logs are missing colors, links are not clickable (from Jenkins UI), seems that anything that has special characters no longer appears in logs

for example, printed error from tools like tflint, flake8, etc no longer appear to the user

Anything else?

No response

Are you interested in contributing a fix?

No response

@ArieLevs ArieLevs added the bug Something isn't working label Aug 12, 2024
@cyrille-leclerc
Copy link
Contributor

We probably know the limitation but I would like to double check please: can you provide a description of the color highlighting and hyperlinks that you are looking for, ideally with an annotated screenshot of pipeline logs with the formatting you are looking for.

The cause is likely to be that Elasticsearch, the first OTel logs backend we supported, didn't support ANSI color invisible chars so we had to extract the rich text formatting annotations from the plain text.

See :

@cyrille-leclerc cyrille-leclerc changed the title logs both in Grafana and through Jenkins config - brakes displayed logs (colors?) logs both in Grafana and through Jenkins config - break displayed logs (colors?) Aug 12, 2024
@cyrille-leclerc cyrille-leclerc changed the title logs both in Grafana and through Jenkins config - break displayed logs (colors?) logs both in Grafana and through Jenkins config - breaks displayed logs (colors?) Aug 12, 2024
@ArieLevs
Copy link
Author

Hi @cyrille-leclerc sure,

here is a screenshot using regular console logs with no otel integration
Screenshot 2024-08-13 at 9 33 00

then, when enabling Store pipeline logs In Loki and visualize logs both in Grafana and through Jenkins logs look like:

  • please note - possible another bug?, after setting this option I only see logs in Grafana and not in UI 😕
    see this log line
    Caught exception evaluating: it.writeLogTo(offset,output) in /job/xxxx/job/xxxx/view/change-requests/job/PR-148/4/console. Reason: com.jayway.jsonpath.PathNotFoundException: Expected to find an object with property ['data'] in path $ but found 'java.lang.String'. This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.
    

logs in Grafana are (were exactly the same in UI)
Screenshot 2024-08-13 at 9 44 47

@cyrille-leclerc
Copy link
Contributor

cyrille-leclerc commented Sep 3, 2024

Update: dealing with logs formatting in logs backends that support ANSI color encoding is more complex than anticipated because Jenkins log formatting is no ANSI color encoding or is more than just ANSI color encoding.
I'll continue to explore this.

@ArieLevs can you please open a bug about the issue

Caught exception evaluating: it.writeLogTo(offset,output) in /job/xxxx/job/xxxx/view/change-requests/job/PR-148/4/console. Reason: com.jayway.jsonpath.PathNotFoundException: Expected to find an object with property ['data'] in path $ but found 'java.lang.String'. This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.

It seems to be specific to your Loki version. Do you use self managed Loki? Which version please?

@kuisathaverat
Copy link
Contributor

It was a designed decision to store logs without the format flags; if you want to keep that format in the Jenkins console view, you can use the mirror option. In this way you send the logs to Loky and keep a local copy in the original way so the format is not lost.

@kuisathaverat kuisathaverat added question Further information is requested and removed bug Something isn't working labels Sep 9, 2024
@ArieLevs
Copy link
Author

ArieLevs commented Sep 15, 2024

Update: dealing with logs formatting in logs backends that support ANSI color encoding is more complex than anticipated because Jenkins log formatting is no ANSI color encoding or is more than just ANSI color encoding. I'll continue to explore this.

@ArieLevs can you please open a bug about the issue

Caught exception evaluating: it.writeLogTo(offset,output) in /job/xxxx/job/xxxx/view/change-requests/job/PR-148/4/console. Reason: com.jayway.jsonpath.PathNotFoundException: Expected to find an object with property ['data'] in path $ but found 'java.lang.String'. This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.

It seems to be specific to your Loki version. Do you use self managed Loki? Which version please?

Done #946
Yes using self managed Loki 3.0.0 (k8s)

@ArieLevs
Copy link
Author

ArieLevs commented Sep 15, 2024

It was a designed decision to store logs without the format flags; if you want to keep that format in the Jenkins console view, you can use the mirror option. In this way you send the logs to Loky and keep a local copy in the original way so the format is not lost.

this actually worked very well, the only thing is I can no long see a "link" to Grafana, similar to how its used with Store pipeline logs In Loki and visualize logs both in Grafana and through Jenkins.
to get the desired logs, I had to randomly search a string that appeared in my console logs, then get the trace_id and only then filter by that.

I'll mark issue as closed as all is actually working as expected, it just feels like end uses of Jenkins will never use this feature, as they don't have a direct link from Jenkins <-> Grafana this way. (but this is still good enough for our infra team to investigate Jenkins and get insights)

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

No branches or pull requests

3 participants