Hi there, I am developing the grafana app in other platforms and I want the same experience with Slack Grafana app. But one thing confused me, for Grafana api we should use service account token, but if userA in our product creates a new incident and we use service account token call the grafana api to create a new incident, How could you tell which user creates the new incident ? Looking forward to your reply. Thanks.
Hi,
With a service account token, Grafana records the service account as the incident creator (createdByUser). The API has no “on behalf of user” option, so you need to record userA’s identity yourself:
Add it as a label when you create the incident. CreateIncident accepts labels →
POST https://<stack>.grafana.net/api/plugins/grafana-irm-app/resources/api/v1/IncidentsService.CreateIncident
Authorization: Bearer <service-account-token>
{
"title": "Checkout API errors",
"severity": "minor",
"isDrill": false,
"labels": [{ "key": "created_by", "label": "userA@example.com" }]
}
If the label key doesn’t exist yet, create it first with FieldsService.AddLabelKey.
Store incidentID ↔ userA in your own database, so your product and Slack messages always show the real creator.
Grafana’s own UI will still show the service account as the creator. The label is how you can see who created it inside Grafana.
@infofcc3 Thanks for your quick support. So we don’t have any to pass the user who do this operation and then display in the Grafana UI.
Hi @sophiesun
Correct, there’s no way to pass userA so that Grafana shows them as the creator. Grafana will show the service account in the UI.
The created_by label from my earlier reply is how you make userA’s identity visible on the incident inside Grafana. Your own database mapping (incidentID ↔ userA) is what lets your product and Slack messages show the real creator.
@infofcc3 Got it. Appreciate for your quick support on this. will reach out if we have issues while integration. Thanks.