https://cypress.io logo
Cypress support for Prometheus / Grafana
# i-need-help
s
Hello Community Was wondering if anyone in the community has had any experience with integrating cypress with Prometheus / Grafana ? If so, do you have guidelines to achieve this? Even a quick few lines would be a massive help to push me in the right direction! Kindest Regards
b
could you clarify what kind of integration you're looking to accomplish?
s
@bland-salesclerk-62828 We are trying to transport any logging / metrics gathered from cypress, so we can have a single source of truth for metrics. be it api logging level that feeds grafana, or metrics / logging from automation
p
I do it, but i use InfluxDb instead of prometheus and grafana to just hit the endpont at the end of the test run. Utilize the
Copy code
js
  on("after:run", async (results) => {
inside the index.js to send the results i want from my run
s
Brilliant! so it is possible! What are you comsuming from this? Pass Fail? Or the logs themselves ?? Sorry for the questions
p
Copy code
js
    const percentFailed = (
      (results.totalFailed / results.totalTests) *
      100
    ).toFixed(2);

    const percentPassed = (
      (results.totalPassed / (results.totalTests - results.totalPending)) *
      100
    ).toFixed(2);
    const skipped = results.totalSkipped
    const endTimestamp = results.endedTestsAt
Just log the results and pick what you need from that json
tbh since i got the cypress cloud I stopped logging it, only use those for my discord channel that shoots a message every time a test fails