A guide on creating a Grafana folder using Pulumi

After successfully installing and importing Grafana dashboards in an Azure Kubernetes Service using Pulumi through a HelmRelease Custom Resource Definition of the kube-prometheus-stack, I have been able to configure ConfigMaps to import dashboards stored as JSON files.

Now, my goal is to organize these imported dashboards into custom folders within Grafana.

I am facing two main challenges: creating folders (first problem) and specifying the folder for each imported dashboard.

For example, here is how I currently import a dashboard (which ends up in the root folder in Grafana):

const myDashboard = fs.readFileSync(
  'dashboards/myDashboard.json',
  'utf-8'
);

new k8s.core.v1.ConfigMap(
  'my-dashboard-cm',
  {
    metadata: {
      name: 'my-dashboard',
      namespace: args.namespace,
      labels: { grafana_dashboard: '1' },
    },
    data: { 'my-dashboard.json': JSON.stringify(JSON.parse(myDashboard)) },
  },
  { parent: this }
);

Any assistance on how to create custom folders and assign imported dashboards to them would be greatly appreciated!

Answer №1

To specify the location of your dashboard, use the folder annotation k8s-sidecar-target-directory.

Below is an example of how it should appear on a Pulumi object.

new k8s.core.v1.ConfigMap(
  'my-dashboard-cm',
  {
    metadata: {
      name: 'my-dashboard',
      namespace: args.namespace,
      labels: { grafana_dashboard: '1' },
      annotations : { "k8s-sidecar-target-directory" : "/tmp/dashboards/yourfolder"                                     }
    },
    data: { 'my-dashboard.json': JSON.stringify(JSON.parse(myDashboard)) },
  },
  { parent: this }
);

Ensure that you set

sidecar.dashboards.provider.foldersFromFilesStructure:true
in your main chart values to maintain consistent folder names in the Grafana menu.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue with npm resolution due to package requiring another third-party dependency

I'm encountering an issue with a requirement and I'm hoping for some assistance. I currently have a package called @unicoderns/orm that relies on mysql, which can be found at https://github.com/unicoderns/ORM Now I'm working on developing ...

Dynamic Material UI Timeline

I am facing a challenge with making the Timeline in Material UI responsive for the first time. Currently, I have it set to align 'alternate', but I want it to switch to align 'left' when viewed on mobile or certain screen widths. I have ...

Establishing a connection between TypeScript and MongoDB

Whenever I try to add the mongo connection to the request, I encounter an error. The error message says: 'Property 'dbClient' does not exist on type 'Request<ParamsDictionary>'. I want the connection to be accessible witho ...

Can you explain the concept of being "well-typed" in TypeScript?

The website linked below discusses the compatibility of TypeScript 2.9 with well-defined JSON. What exactly does "well-typed" JSON mean? As far as I understand, JSON supports 6 valid data types: string, number, object, array, boolean, and null. Therefore, ...

The parameters of a generic class in Typescript are customizable and

Currently working on programming an internal abstract class for a project, and I need it to be generic in order to make it extendable. The goal is to have my class named as if it were extending the T template, like Sample extends T, so that all parameters ...

Utilizing ngx-bootstrap to enhance Bootstrap dropdown functionality

I initially tried to set up ngx-bootstrap in Angular 2 by using the following command: npm install ngx-bootstrap bootstrap --save Then, I included these lines in angular-cli.json: "../node_modules/bootstrap/dist/css/bootstrap.min.css". In app.compone ...

What are some methods for extracting a value from a separate webpage and saving it as a variable in my code?

I am utilizing graphite to obtain statistics and would like to display a justgage gauge for a specific variable. Graphite provides values in either JSON format: [{"target": "snmp.ssbSubstation.realEnergy.1", "datapoints": [[4511552439.0, 1417540920]]}] o ...

Looking for a method to efficiently populate an array with values in Typescript

Here is an example of how I work with arrays in my code: var alphas: string[]; alphas = ['abc1', 'abc2', 'abc3']; // (this array can be changed) My modal class looks like this: export class Team { TeamName: string; } To ...

Enhance the performance of your React/NextJS app by controlling the rendering of a component and focusing on updating

I'm facing an issue with my NextJS application that showcases a list of audio tracks using an <AudioTrackEntry> component. This component receives props like the Track Title and a Link to the audio file from an external data source. Within the ...

Leveraging interfaces with the logical OR operator

Imagine a scenario where we have a slider component with an Input that can accept either Products or Teasers. public productsWithTeasers: (Product | Teaser)[]; When attempting to iterate through this array, an error is thrown in VS Code. <div *ngFor= ...

Creating a signature for a function that can accept multiple parameter types in TypeScript

I am facing a dilemma with the following code snippet: const func1 = (state: Interface1){ //some code } const func2 = (state: Interface2){ //some other code } const func3: (state: Interface1|Interface2){ //some other code } However, ...

TypeScript class that utilizes internal functions to implement another class

In my journey of exploration, I decided to try implementing a class within another class in TypeScript. Here is the code snippet I came up with and tested on the Playground link: class A { private f() { console.log("f"); } public g() { console.lo ...

Encountering an Issue: The formGroup function requires an instance of a FormGroup. Kindly provide one

I am a beginner with Angular 2 and despite reviewing numerous stack overflow answers, I still can't resolve my issue. I have recently started learning about angular reactive forms and wanted to try out my first example but I'm facing some diffic ...

Can a string array be transformed into a union type of string literals?

Can we transform this code snippet into something like the following? const array = ['a', 'b', 'c']; // this will change dynamically, may sometimes be ['a', 'e', 'f'] const readonlyArray = arr ...

Is it possible to dynamically pass a component to a generic component in React?

Currently using Angular2+ and in need of passing a content component to a generic modal component. Which Component Should Pass the Content Component? openModal() { // open the modal component const modalRef = this.modalService.open(NgbdModalCompo ...

The error message "vimeo/player.js - Unable to access property 'nativeElement' as it is undefined" appeared

I am encountering difficulties integrating vimeo/player.js into my angular-cli application. There isn't a supporting library for Angular 4, so I'm following the steps in the README.md under "Using with a module bundler". I created a vimeo-player ...

Adding innerHTML content to tooltip title using typescript in an Angular project

I have encountered an issue while trying to display HTML content inside a tooltip element's title attribute. The HTML content is not rendering as expected and appears as text instead. Let me outline the structure of my Angular project: library.comp. ...

Importing components in real-time to generate static sites

My website has a dynamic page structure with each page having its unique content using various components. During the build process, I am statically pre-rendering the pages using Next.js' static site generation. To manage component population, I have ...

Update the disabled state following the onInit event

Currently, I am developing an angular application at my workplace that requires implementing permissions. The backend stores permissions as either 1 or 0, and the frontend queries a service to retrieve the user's permission. If the user lacks permissi ...

What is the best way to assign the value of an HTTP GET request to a subarray in Angular 8

Attempting to store data in a sub-array (nested array) but despite receiving good response data, the values are not being pushed into the subarray. Instead, an empty array is returned. for (var j=0;j<this.imagesdataarray.length;j++){ this.http.g ...