influxdata / helm-charts

Official Helm Chart Repository for InfluxData Applications
MIT License
233 stars 330 forks source link

[chronograf] Support loading custom dashboards #121

Closed mkerins closed 2 years ago

mkerins commented 4 years ago

It doesn't seem to be possible to include a custom dashboard when installing the chronograf chart. The way I would do it if I was writing the Deployment myself is to create a ConfigMap with the file:

apiVersion: v1
kind: ConfigMap
metadata:
  name: chronograf-dashboard
data:
  custom-dashboard.json: |
    {
      "id": "custom-dashboar",
      "measurement": "apache",
      "app": "apache",
      ...
    }

Then mount it:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: chronograf
  labels:
    app: chronograf
spec:
  replicas: 1
  selector:
    matchLabels:
      app: chronograf
  template:
    metadata:
      labels:
        app: chronograf
    spec:
      containers:
        - name: chronograf
          image: chronograf:latest
          ports:
            - containerPort: 8888
          volumeMounts:
          - name: dashboard-volume
            mountPath: /usr/share/chronograf/resources
      volumes:
        - name: dashboard-volume
          configMap:
            name: chronograf-dashboard

I'm willing to work on this but waiting on my company to sign the CCLA. In the meantime is there another way to include a custom dashboard? Thanks.

russorat commented 4 years ago

@mkerins thank you! that looks like the right way IMO. you might also need to pass an additional param to chronograf when it starts. https://github.com/influxdata/docs.influxdata.com/issues/2905

kelseiv commented 4 years ago

Thank you, @russorat! @mkerins if you change your custom dashboard .json file extension to .dashboard and put the file in the /canned directory rather than the /resources directory, does that work?

mkerins commented 4 years ago

Thanks for the suggestion @kelseiv , but as far as I know the canned dashboards are only available when connecting to a data source for the first time. Since I'm pre-configuring the datasource during a helm pre-install hook that's not available. What I ended up doing is creating two configmaps: one for the connection to influxdb and one for the dashboard. The connection to influxdb is mounted at /usr/share/chronograf/resources and that path is set as the value of $RESOURCES_PATH. The dashboard was trickier, I wrote it to a JSON file then loaded it using curl. The gist is here.

This works for my purposes but I had to basically copy and paste the service and deployment objects from the chart so will have to manually patch any changes to the upstream chart.

alespour commented 2 years ago

Closed as stale. Please reopen if still needs to be addressed.