I am new to Grafana and trying to understand how I can use it for my use case - which is to visualize front-end logs. From various docs and tutorials, my understanding is that Grafana provides integrations to different kind of servers such as Apache, Node.js etc. but couldn’t find anything specific to Single-Page Apps (SPAs) created using React, Angular, Vue etc.
Specifically, I have a React application which can log the following types of information to any REST endpoint:
- Page views
- API calls with response times
- Errors
- User actions, e.g. mouse clicks, focus & blur events
The output is structured JSON. Here are some examples:
Page view
{
"timestamp": "2022-07-12T17:57:59.559Z",
"level": "info",
"type": "PageView",
"url": "http://grafana.staged-by-discourse.com/demo"
}
API Call
{
"timestamp": "2022-07-12T17:57:59.559Z",
"level": "info",
"type": "ApiCall",
"url": "http://localhost:8080/top-10-movies",
"method": "get",
"startTime": "2022-07-12T17:57:59.559Z",
"endTime": "2022-07-12T17:57:59.600Z",
"durationMillis": 41,
"status": 200,
}
Error
{
"timestamp": "2022-07-12T17:57:59.559Z",
"level": "error",
"type": "UncaughtError",
"message": "Network error"
}
Questions
- What is the easiest way to ingest JSON logs shown above in a store supported by Grafana? Note that the front-end needs a REST endpoint to transmit these logs.
- Since the logs are of mixed types (page views, API calls, errors and user actions), do they need to be separated into different stores? My preference would be to save everything in a single store and use the
type
property to select the desired type. - Are there standardized data structures that Grafana understands better and would make my visualization work easier? I am open to changing the data structures described above.