Skip to content

matthgyver/PS-Grafana

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Powershell module for Grafana

I. Introduction

This module provide a simple collection of Powershell commandlet to manage Grafana by the REST API.

Simple manage Grafana users, folder, permissions ... with a windows commande line tool.

This module required at least Powershell version 5. (I've seen some problems with version 4 and JSON dashboard importation, maybe all other commandlets work great)

All contribution are welcome !

II. Features

1. Common features

To simplify multiple operations, there is some commandlet to store credential. You can use this functions :

  • Storing username / password credential and target URL :
Connect-Grafana -authLogin foobar -authPassword myPassword -url https://foo.bar.com
  • Storing API key credential and target URL :
Connect-Grafana -authToken f00barazertyMynAme1sWa11t3rWh1t3 -url https://foo.bar.com
  • Define the "context" (working organisation for the authenticated user with plaintext method) :
Set-Grafana-Context -url "https://foobar.fr" -authLogin admin -authPassword Passw0rd -orgName "foo bar org."
  • DisConnect- commandlet
Disconnect-Grafana

All commandlet can be used with authentications parameters. Refer to the next chapter for more informations.

2. Special features

Use Get-Help to display all features of a commandlet. By example, "get-help -full New-GrafanaDashboard" will show you that you could create a new dashboard from a template and how to use it.

3. Synthesis

I referenced here all commandlets that will be usefull.

All of them are not developed at this time. I just coded the ones I needed for my job.

Admin features

Commandlet Official API documentation Authentication Status
Get-GrafanaSettings Link Token & Plaintext not started
Get-GrafanaStats Link Token & Plaintext not started

Alerting

Commandlet Official API documentation Authentication Status
Get-GrafanaAlerts Link Token & Plaintext not started
Pause-GrafanaAlerts Link Token & Plaintext not started
Get-GrafanaAlertsNotifications Link Token & Plaintext not started
New-GrafanaAlertsNotifications Link Token & Plaintext not started
Set-GrafanaAlertsNotifications Link Token & Plaintext not started
Remove-GrafanaAlertsNotifications Link Token & Plaintext not started

Annotations features

Commandlet Official API documentation Authentication Status
Get-GrafanaAnnotations Link Token & Plaintext not started
New-GrafanaAnnotations Link Token & Plaintext not started
Set-GrafanaAnnotations Link Token & Plaintext not started
Remove-GrafanaAnnotations Link Token & Plaintext not started

Authentication features

Commandlet Official API documentation Authentication Status
New-GrafanaApikey Link Token & Plaintext not started
Remove-GrafanaApikey Link Token & Plaintext not started

Dashboard features

Commandlet Official API documentation Authentication Status
New-GrafanaDashboard Link Token & Plaintext OK
Get-GrafanaDashboard Link Token & Plaintext OK
Get-GrafanaDashboardContent Token & Plaintext OK
Move-GrafanaDashboard Token & Plaintext OK
Remove-GrafanaDashboard Link Token & Plaintext OK
Set-GrafanaDashboard Custom function to move or rename a dashboard Token & Plaintext OK
Get-GrafanaHomeDashboard Link Token & Plaintext not started
Get-GrafanaDashboardVersion Link Token & Plaintext OK
Restore-GrafanaDashboard Link Token & Plaintext not started
Compare-GrafanaHomeDashboard Link Token & Plaintext not started

Datasource features

Commandlet Official API documentation Authentication Status
Get-GrafanaDatasource Link Token & Plaintext OK
New-GrafanaDatasource Link Token & Plaintext not started
Set-GrafanaDatasource Link Token & Plaintext not started
Remove-GrafanaDatasource Link Token & Plaintext not started

Folder features

Commandlet Official API documentation Authentication Status
Get-GrafanaFoldersList Link Token & Plaintext OK
Get-GrafanaFolder Token & Plaintext OK
New-GrafanaFolder Link Token & Plaintext OK
Remove-GrafanaFolder Link Token & Plaintext OK
Set-GrafanaFolder Link Token & Plaintext OK

Organisation features

Commandlet Official API documentation Authentication Status
Get-GrafanaOrganisation Link Plaintext only OK
New-GrafanaOrganisation Link Plaintext only OK
Set-GrafanaOrganisation Link Plaintext only OK
Add-GrafanaUserInOrganisation Link Plaintext only OK
Get-GrafanaOrganisationUsers Link Plaintext only OK
Set-GrafanaUserRoleInOrganisation Link Token & Plaintext OK
Remove-GrafanaUserFromOrganisation Link Token & Plaintext OK

Permissions features

Commandlet Official API documentation Authentication Status
Get-GrafanaFolderPermissions Link Token & Plaintext OK
New-GrafanaFolderPermissions Link Token & Plaintext OK
Remove-GrafanaFolderPermissions Link Token & Plaintext OK
Get-GrafanaDashboardPermissions Link Token & Plaintext OK
New-GrafanaDashboardPermissions Link Token & Plaintext OK
Remove-GrafanaDashboardPermissions Link Token & Plaintext OK

Other features

Commandlet Official API documentation Authentication Status
Get-GrafanaSettings Link Token & Plaintext not started

Preferences features

Commandlet Official API documentation Authentication Status
Get-GrafanaCurrentUserPrefs Link Token & Plaintext not started
Set-GrafanaCurrentUserPrefs Link Token & Plaintext not started
Get-GrafanaCurrentOrgPrefs Link Token & Plaintext not started
Set-GrafanaCurrentOrgPrefs Link Token & Plaintext not started

Snapshots features

Commandlet Official API documentation Authentication Status
New-GrafanaSnapshot Link Token & Plaintext not started
Get-GrafanaSnapshot Link Token & Plaintext not started
Remove-GrafanaSnapshot Link Token & Plaintext not started

Team features

Commandlet Official API documentation Authentication Status
New-GrafanaTeam Link Token & Plaintext OK
Get-GrafanaTeam Link Token & Plaintext OK
Set-GrafanaTeam Link Token & Plaintext OK
Remove-GrafanaTeam Link Token & Plaintext OK
Get-GrafanaTeamMembers Link Token & Plaintext OK
Add-GrafanaTeamMember Link Plaintext only OK

Users Features

Commandlet Official API documentation Authentication Status
Get-GrafanaUser Link Plaintext only OK
New-GrafanaUser Link Plaintext only OK
Set-GrafanaUser Link Plaintext only OK
Get-GrafanaUserOrgs Link Plaintext only OK
Remove-GrafanaUser Link Plaintext only OK
Set-GrafanaContext Link Plaintext only OK
Set-StarGrafanaDashboard Link Token & Plaintex not started

Custom features

Commandlet Official API documentation Authentication Status
Connect-Grafana See chapter 'Common features' Token & Plaintext OK
Disconnect-Grafana See chapter 'Common features' OK

III. Evolutions

  • Code all commandlets
  • Improve parameter verifications
  • Add pipe features

About

Powershell module to manage Grafana

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published