Open nvuillam opened 1 month ago
When running Megalinter GitHub workflow, should there be output from the API_REPORTER reporter showing a message that logs were sent to Grafana?
I have followed the API Reporter(Grafana) guide but Grafana is not showing any log or metric information received when run as a GitHub action. I get "No data" in the Grafana dashboards provided by Megalinter. The Grafana dashboard home pages reports 0 (zero) for Metrics and Logs.
Am I unsure where this is failing as I do not see logs in the Megalinter output, even with API_REPORTER_DEBUG: true
I had created Repository secrets as I want to use Grafana dashboards for multiple repositories. I will check if that is the cause of the fail (but I dont see errors in the log)
Example project created from the MegaLinter docs (public GitHub repo): https://github.com/practicalli/megalinter-test
NOTE: I've tried this on three separate GitHub repositories and the bearer token rather than basic auth, but all with the same results :(
@practicalli-johnny it seems that nothing is sent to Grafana :( You can use Grafana dashboards for multiple repos, they are build for that :)
But... I think your API_REPORTER is not active, otherwise you would see such logs
(source: https://github.com/oxsecurity/megalinter/actions/runs/10949911462/job/30404111491 )
After checking your config & logs... it looks good, so I must be missing something... I investigate :)
I added some debug outputs to help investigate
@practicalli-johnny please could you try with beta version and LOG_LEVEL: DEBUG
then share the job execution link ? :)
Added LOG_LEVEL: DEBUG to the megalinter.yaml file and updated the Megalinter GitHub workflow to use @beta
uses: oxsecurity/megalinter/flavors/java@beta
GitHub actions workflow output: no data in Grafana dashboard.
I will try the main megalinter image rather than the java flavour.
It should work the same with any flavor :'(
@practicalli-johnny I don't understand why I can't find any [Reporters] in the log :'(
Please can you try to add the LOG_LEVEL: true directly in the Github workflow variables and not the .mega-linter.yml ?
Updated LOG_LEVEL to be only in the GitHub Workflow yaml file.
There is a log entry now about API REPORTER, but no data in Grafana :( - Edit: I only looked at the Grafana home page (which reports zero logs) and not the dashboards which were probably working - the dashboards do now work.
[Api Reporter Metrics] Using Basic Auth
Starting new HTTPS connection (1): influx-prod-24-prod-eu-west-2.grafana.net:443
[https://influx-prod-24-prod-eu-west-2.grafana.net:443](https://influx-prod-24-prod-eu-west-2.grafana.net/) "POST /api/v1/push/influx/write HTTP/11" 204 0
[Api Reporter Metrics] Successfully posted data to ***
[Api Reporter Metrics] linter_run,source=MegaLinter,orgIdentifier=main,gitIdentifier=megalinter-test/main,gitRepoName=megalinter-test,gitBranchName=main,descriptor=ACTION,linter=actionlint,linterKey=ACTION_ACTIONLINT numberErrorsFound=0,numberFilesFound=1,elapsedTime=0.02
@practicalli-johnny according to the logs, the data is sent to Grafana :)
Please can you check is Explore -> Logs for events with source "MegaLinter" ?
Megalinter sent logs to Grafana at 9:50 this morning, so when I added LOG_LEVEL: DEBUG
to the megalinter GitHub workflow yaml file.
The dashboards are now working too:
The home page of Grafana suggests the logs arent working, perhaps its because the number of logs is too low and being rounded down (or they are not looking at the right log source).
Later today I will change back to the java flavour of megalinter and confirm if logs are still being sent.
Thanks for all your help with diagnosing this issue. I will configure all the other Practicalli open source GitHub projects and experiment with the Grafana dashboards. I'll write up how I am using this all in a blog post later in the month. Thanks again.
@practicalli-johnny great feedback, many thanks :) If you have ideas of better dashboards than the very simple and ugly ones I created, I'd be delighted to see them ! :)
@practicalli-johnny Seing this one I wonder if you didn't select the wrong datasource when matching dashboards & sources at the import
Maybe selected prometheus instead of loki, or the contrary ? On main dashboard you're supposed to have only one number by linter (the number of errors) , and the elapsed time is available in sub-dashboards after clicking on the button
Hi,
I was about to create an issue of the sending of metrics to Grafana not working on flavors.
Then I found this conversation and tried to solve my issue like you did (by adding ENABLE_LOGS=true
), but it didn't worked, even on beta flavors.
Tell me if you'd prefer a new specific issue.
My findings so far:
using oxsecurity/megalinter/flavors/javascript@beta
(or v8):
--> the workflow doesn't even try to send data
e.g. https://github.com/nabondance/Trailhead-Stats/actions/runs/11042265194/job/30674254975?pr=112
using oxsecurity/megalinter@v8.0.0
:
--> the workflow send data and the grafana works perfectly
e.g. https://github.com/nabondance/Trailhead-Stats/actions/runs/11041968876/job/30673385205
The grafana log, with the only try without flavors sending data:
The env
in the MegaLinter step:
API_REPORTER: true
API_REPORTER_URL: ${{ secrets.API_REPORTER_URL }}
API_REPORTER_BASIC_AUTH_USERNAME:
${{ secrets.API_REPORTER_BASIC_AUTH_USERNAME }}
API_REPORTER_BASIC_AUTH_PASSWORD:
${{ secrets.API_REPORTER_BASIC_AUTH_PASSWORD }}
API_REPORTER_METRICS_URL: ${{ secrets.API_REPORTER_METRICS_URL }}
API_REPORTER_METRICS_BASIC_AUTH_USERNAME:
${{ secrets.API_REPORTER_METRICS_BASIC_AUTH_USERNAME }}
API_REPORTER_METRICS_BASIC_AUTH_PASSWORD:
${{ secrets.API_REPORTER_METRICS_BASIC_AUTH_PASSWORD }}
API_REPORTER_DEBUG: true
ENABLE_LOGS: true
LOG_LEVEL: DEBUG
I really don't understand why it is not working when using a flavor and why the solution you found doesn't work for me.
I'm available if you have questions or need to test more things.
@nabondance (coucou Nathan je t'ai reconnu 😄 ) > Please can you try with beta version of a flavor ? There are new logs showing activation / deactivation of Reporters, it should help
(Bravo ! 😁)
Tried with the step:
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/javascript@beta
id: ml
env:
VALIDATE_ALL_CODEBASE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Uncomment to use ApiReporter (Grafana)
API_REPORTER: true
API_REPORTER_URL: ${{ secrets.API_REPORTER_URL }}
API_REPORTER_BASIC_AUTH_USERNAME:
${{ secrets.API_REPORTER_BASIC_AUTH_USERNAME }}
API_REPORTER_BASIC_AUTH_PASSWORD:
${{ secrets.API_REPORTER_BASIC_AUTH_PASSWORD }}
API_REPORTER_METRICS_URL: ${{ secrets.API_REPORTER_METRICS_URL }}
API_REPORTER_METRICS_BASIC_AUTH_USERNAME:
${{ secrets.API_REPORTER_METRICS_BASIC_AUTH_USERNAME }}
API_REPORTER_METRICS_BASIC_AUTH_PASSWORD:
${{ secrets.API_REPORTER_METRICS_BASIC_AUTH_PASSWORD }}
API_REPORTER_DEBUG: true
ENABLE_LOGS: true
LOG_LEVEL: DEBUG
The log with as much debug as possible: https://github.com/nabondance/Trailhead-Stats/actions/runs/11042265194/job/30695747348 Still nothing trying to send data to loki/prom, the reporters doesn't start
I understand the goal and how to use the flavors, sadly I don't understand how they are generated, I can't help to find if it is related to the flavors themselves
Edit. Additional information: The token has been used at the time the workflow ran (but still no data log):
I recreated both dashboards and they seem correct now.
It seems there is an issue with the api reporter when using a megalinter flavor (java and documentation tested)
Using megalinter without a flavor publishes data to Grafana for both v8.0.0 and beta versions.
Using the Java flavor of megalinter, v8.0.0 or beta, the megalinter log does not include messages about the API reporter connecting.
The "Latest run" value in the DASH - ML Errors & Elapse dashboard does not show a date timestamp corresponding to a GitHub workflow run when the java flavour is used.
I also get Annotation warnings with the java flavour, which I do not get with the megalinter standard image
The documentation flavor (v8.0.0 or beta) seems to have the same issues as java flavor - no api message, no updated latest run and annotation warnings.
I havent tried any of these images via Docker as yet, only via a GitHub workflow.
All variants were tried on the same practicalli/megalinter-test GitHub repository. All uses:
examples are include in the GitHub workflow yaml file.
One thing that seems easy to get tripped up on is that some linters will show "No Data" in the dashboard even if logs were pushed to Grafana. Looking at the first few sections of the "Errors & Elapse" dashboard can easily lead people to thinking that no logs have been pushed, if they dont scroll down many pages to a linter that does have data.
When only running a very small amount of linters it is easy to believe that no logs are being passed.
If the linters that have no data are collapsed then it is easier to see that new logs have been published on the "Errors & Elapse" dashboard.
I typically remove the "All" filter from the dashboard and add the few specific linter names I want to see. This makes it very easy to see new logs have been published, along with the time stamp.
Would a new dashboard be needed for each flavor? Or does the dashboard parse and display only the linters available from the last published logs? So if a specific flavor of megalinter is used, will it only show the linters on the "Errors & Elipse" dashboard?
It would be useful to share how the dashboards have currently been put together, as at first glance it not obvious what all the config means (I can make a few rough guesses). Ideally I'd like to define a dashboard that only has the linters I am most interested in, to avoid having to update filters or do lots of scrolling each time.
I have only been able to make API_REPORTER work with the default Megalinter version (flavor) which means disabling more specific linter in the config, e.g. Repository has more linters in the default Megalinter version)
Dashboard update:
Now the Grafana trial has expired and logs are only retained for 14 days, the dashboard is only showing the specific linters that have been run (and all have data to show).
This makes the provided megalinter Errors & Elapsed dashboard much simpler to understand, especially as I have only been pushing an API_REPORT from the one repository.
I wonder if there is additional configuration on the Megalinter dashboards to be scoped within a specific Git repository?
FYI i'm still struggling to find why flavors do not call ApiReporter 😨 That's kind of a great mystery... and the new limitations about Docker Hub for internal CI do not help, but I really plan to make it work for 8.1.0 :)
I was checking the Changelog to check the version of the various linters, and while the Changelog says that golangci-lint
was updated to v1.60.1
, that isn't true for the cupcake
flavor.
Any chance you can cut a patch release to fix it?
$ docker run --rm -it --entrypoint=/bin/golangci-lint docker.io/oxsecurity/megalinter-cupcake:v8 --version
golangci-lint has version 1.59.1 built with go1.22.3 from 1a55854a on 2024-06-09T18:08:33Z
$ docker run --rm -it --entrypoint=/bin/golangci-lint docker.io/oxsecurity/megalinter:v8 --version
golangci-lint has version 1.60.1 built with go1.23.0 from 3298c104 on 2024-08-14T01:15:05Z
Run
npx mega-linter-runner@latest --upgrade
to upgrade to MegaLinter v8 :)You can see release notes
If you are a Grafana expert and would like to help by configuring some great Dashboards using MegaLinter Prometheus Metrics and Loki logs, please contact me :)
If you are not a Grafana expert but have ideas about some relevant Dashboards we could create, please post an issue :)
If you see any problem with MegaLinter v8, please post here so it will be processed in priority :)
Video presentation:
LinkedIn post to like & share :)