Skip to content

feat: grafana component#183

Open
bornast wants to merge 2 commits intomasterfrom
feat/grafana-comp
Open

feat: grafana component#183
bornast wants to merge 2 commits intomasterfrom
feat/grafana-comp

Conversation

@bornast
Copy link
Member

@bornast bornast commented Mar 16, 2026

This PR introduces the Grafana builder and component. It's the first in a series of upcoming PRs.
Dashboard configuration will be covered in the next one.
To instantiate the Grafana component, the following env variables need to be set: GRAFANA_URL, GRAFANA_AUTH, GRAFANA_CLOUD_ACCESS_POLICY_TOKEN.

@bornast bornast requested review from droguljic and mandryllo March 16, 2026 13:36
{
stackSlug,
slug: 'grafana-amazonprometheus-datasource',
version: 'latest',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make this configurable and use the latest as a default?
It seems convenient to have the ability to pinpoint a specific version.

export namespace Grafana {
export type PrometheusConfig = {
prometheusEndpoint: pulumi.Input<string>;
region: pulumi.Input<string>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should region be optional and fallback to the current AWS region used by the stack?

super('studion:grafana:Grafana', name, {}, opts);

if (args.prometheus) {
const ampRole = this.createAmpRole(name, args.tags);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set ampRole on the instance, e.g. this.ampRole = ...

Comment on lines +43 to +45
if (!grafanaUrl) {
throw new Error('GRAFANA_URL environment variable is not set.');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stack config should be the first option, env is the fallback, e.g.

const config = new pulumi.Config('grafana');

const url = grafanaConfig.get('url') ?? process.env.GRAFANA_URL; 

NOTE: This should apply to other props mentioned in PR description since they are provider options.

import * as grafana from '@pulumiverse/grafana';

// Fixed AWS account ID owned by Grafana Cloud, used to assume roles in customer accounts.
const GRAFANA_CLOUD_AWS_ACCOUNT_ID = '008923505280';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this is exposed in GH, but the docs do not mention there is just one fixed account ID.
Remove the constant and make it a config option.

super('studion:grafana:Grafana', name, {}, opts);

if (args.prometheus) {
const ampRole = this.createAmpRole(name, args.tags);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future we would have more data sources than just prometheus so I would recommend:

  • renaming this iam role to more generic name (grafanaIamRole or something)
  • separating creating that iam role and amp role policy to two methods
  • creating iam role outside this condition
  • creating amp role policy inside this condition (grouped with creating promtheus data source)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants