Skip to content

Commit

Permalink
Add datasources UID (#242)
Browse files Browse the repository at this point in the history
* Add datasources UID

* remove Alertmanager datasource

* set Mimir Alertmanager datasource to default

---------

Co-authored-by: Hervé Nicol <[email protected]>
  • Loading branch information
TheoBrigitte and hervenicol authored Feb 6, 2025
1 parent f0c7419 commit 88c16ad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add datasources UID

### Changed

- improved run-local port-forward management
Expand All @@ -18,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed

- Remove turtle related Alertmanager configuration
- Remove Alertmanager datasource

## [0.13.1] - 2025-01-30

Expand Down
18 changes: 6 additions & 12 deletions pkg/grafana/grafana.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,11 @@ var SharedOrg = Organization{

// We need to use a custom name for now until we can replace the existing datasources.
var defaultDatasources = []Datasource{
{
Name: "Alertmanager",
Type: "alertmanager",
IsDefault: true,
URL: "http://alertmanager-operated.monitoring.svc:9093",
Access: datasourceProxyAccessMode,
JSONData: map[string]interface{}{
"handleGrafanaManagedAlerts": false,
"implementation": "prometheus",
},
},
{
Name: "Mimir Alertmanager",
UID: "gs-mimir-alertmanager",
Type: "alertmanager",
IsDefault: false,
IsDefault: true,
URL: "http://mimir-alertmanager.mimir.svc:8080",
Access: datasourceProxyAccessMode,
JSONData: map[string]interface{}{
Expand All @@ -49,6 +39,7 @@ var defaultDatasources = []Datasource{
},
{
Name: "Mimir",
UID: "gs-mimir",
Type: "prometheus",
IsDefault: true,
URL: "http://mimir-gateway.mimir.svc/prometheus",
Expand All @@ -63,6 +54,7 @@ var defaultDatasources = []Datasource{
},
{
Name: "Loki",
UID: "gs-loki",
Type: "loki",
URL: "http://loki-gateway.loki.svc",
Access: datasourceProxyAccessMode,
Expand Down Expand Up @@ -193,6 +185,7 @@ func ConfigureDefaultDatasources(ctx context.Context, grafanaAPI *client.Grafana
logger.Info("creating datasource", "datasource", datasource.Name)
created, err := grafanaAPI.Datasources.AddDataSource(
&models.AddDataSourceCommand{
UID: datasource.UID,
Name: datasource.Name,
Type: datasource.Type,
URL: datasource.URL,
Expand All @@ -214,6 +207,7 @@ func ConfigureDefaultDatasources(ctx context.Context, grafanaAPI *client.Grafana
_, err := grafanaAPI.Datasources.UpdateDataSourceByID(
strconv.FormatInt(datasource.ID, 10),
&models.UpdateDataSourceCommand{
UID: datasource.UID,
Name: datasource.Name,
Type: datasource.Type,
URL: datasource.URL,
Expand Down
1 change: 1 addition & 0 deletions pkg/grafana/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Organization struct {

type Datasource struct {
ID int64
UID string
Name string
IsDefault bool
Type string
Expand Down

0 comments on commit 88c16ad

Please sign in to comment.