Skip to content

artem-sedykh/Grafana.Api.Client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grafana.Api.Client NuGet Downloads

=============================================

Status

Build status

C# Grafana api client

Native grafana annotations

Annotations

var uri = new Uri("http://localhost:3000/");

//grafana configurations /org/apikeys
var apiKey = "....";

var annotationService = new AnnotationService(uri, apiKey);

var dashboardService = new DashboardService(uri, apiKey);

//find dashboard id
//Uid may be edited in dashboard settings
var dashboardResponse = dashboardService.GetDashboardByUid("test_dashboard");

var dashboardId = dashboardResponse.Dashboard.Id;

//Epoch datetime in milliseconds
var start = DateTime.UtcNow.AddMinutes(-15).ToGrafanaTimestamp();

//Epoch datetime in milliseconds
var stop = DateTime.UtcNow.ToGrafanaTimestamp();

//create annotation 
annotationService.Create(new CreateAnnotationRequest
{
    DashboardId = dashboardId,
    IsRegion = true,
    Tags = new[] {"deploy", Environment.MachineName },
    Text = $"Deploy on {Environment.MachineName}",
    Time = start,
    TimeEnd = stop
});

adding grafana api key

ApiKey

set dashboard uid

dashboard uid

Releases

No releases published

Packages

No packages published

Languages