Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable/grafana] Can't import dashboard from json file #12679

Closed
petrokashlikov opened this issue Mar 29, 2019 · 16 comments

Comments

@petrokashlikov
Copy link

@petrokashlikov petrokashlikov commented Mar 29, 2019

Is this a request for help?:
Yes

Is this a BUG REPORT or FEATURE REQUEST? (choose one):

Version of Helm and Kubernetes:

Helm:
Version{SemVer:"v2.10.0", GitCommit:"9ad53aac42165a5fadc6c87be0dea6b115f93090", GitTreeState:"clean"}
Kubernetes:
Server Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.7-gke.12", GitCommit:"06f08e60069231bd21bdf673cf0595aac80b99f6", GitTreeState:"clean", BuildDate:"2019-02-25T20:37:10Z", GoVersion:"go1.10.8b4", Compiler:"gc", Platform:"linux/amd64"}

Which chart:
[stable/grafana]

What happened:
I'm trying to setup grafana to load charts from dashboards folder in chart as per documentation. Created dashboard folder in my chart folder and put sample redis.json file there. In values.yaml configured following:

dashboardProviders:
  dashboardproviders.yaml:
    apiVersion: 1
    providers:
    - name: 'default'
      orgId: 1
      folder: ''
      type: file
      disableDeletion: false
      editable: true
      options:
        path: /var/lib/grafana/dashboards/default
dashboards:
  default:
    redis:
      file: dashboards/redis.json
    prometheus-stats:
      gnetId: 2
      revision: 2
      datasource: Prometheus
#    local-dashboard:
#      url: https://example.com/repository/test.json
#    local-dashboard-base64:
#      url: https://example.com/repository/test-b64.json
#      b64content: true`

When I deploy grafana prometheus-stats dashboard is loaded, but redis one no. I see that chart created config map with following contents. Also in container file redis.json was copied to /var/lib/grafana/dashboards/default, but it is empty. Does it mean it was not able to parse json or something like that, as there is empty value?
If I run
helm install --dry-run --debug --name grafana --namespace monitoring -f values.yaml stable/grafana
there is no errors thrown.

apiVersion: v1
kind: ConfigMap
metadata:
  name: grafana-dashboards-default
  labels:
    app: grafana
    chart: grafana-3.0.1
    release: grafana
    heritage: Tiller
    dashboard-provider: default
data:
  redis.json:
    ""

What you expected to happen:

Expect dashboard to be imported

How to reproduce it (as minimally and precisely as possible):

Using helm install command and modifying values.yaml file with above values
helm install --name grafana --namespace monitoring -f values.yaml stable/grafana

Anything else we need to know:

@petrokashlikov petrokashlikov changed the title [stable/grafana] Can't import dashboard from son file [stable/grafana] Can't import dashboard from json file Mar 29, 2019
@maorfr

This comment has been minimized.

Copy link
Member

@maorfr maorfr commented Mar 30, 2019

There is a ` at the end of the default dashboards provider. Is this a typo?

@petrokashlikov

This comment has been minimized.

Copy link
Author

@petrokashlikov petrokashlikov commented Apr 1, 2019

There is a ` at the end of the default dashboards provider. Is this a typo?

Yep @maorfr sorry, this is from formatting here

@frosenberg

This comment has been minimized.

Copy link

@frosenberg frosenberg commented Apr 2, 2019

It seems to work for me. I have the same dashboardProviders section. In addition, I have the following key set:

dashboardsConfigMaps:
  default: "grafana-dashboard"

The value grafana-dashboard is the name of a ConfigMap in the same namespace. The content looks like this:

apiVersion: v1
data:
  gain-dashboard.json: "cut out for brevity" 
kind: ConfigMap
metadata:
  creationTimestamp: "2019-04-01T08:14:07Z"
  name: grafana-dashboard
  namespace: monitoring
  resourceVersion: "1039344"
  selfLink: /api/v1/namespaces/monitoring/configmaps/grafana-dashboard
  uid: 1ec73781-5456-11e9-bfc8-42010a9c00b0

After deploying, I can see the following on the grafana container:

$ kubectl -n monitoring exec -it grafana-68cddfcf4-kq9s5 ls /var/lib/grafana/dashboards/default
gain-dashboard.json

The content of gain-dashboard.json corresponds to the content loaded into the ConfigMap.

In addition is the the dashboardProviders file in the following location:

$ kubectl -n monitoring exec -it grafana-68cddfcf4-kq9s5 ls /etc/grafana/provisioning/dashboards
dashboardproviders.yaml

I also configured a datasource but I omit that as it does not seem to be your issue.

@petrokashlikov

This comment has been minimized.

Copy link
Author

@petrokashlikov petrokashlikov commented Apr 2, 2019

Hi @frosenberg , thanks for helping out here. But it seems in your case you are actually loading dashboard from config map? My intention was to load from file in chart subfolder "dashboards", as per readme in chart repo. I've highlighted relevant section

There are a few methods to import dashboards to Grafana. Below are some examples and explanations as to how to use each method:

dashboards:
default:
some-dashboard:
json: |
{
"annotations":

      ...
      # Complete json file here
      ...

      "title": "Some Dashboard",
      "uid": "abcd1234",
      "version": 1
    }
**custom-dashboard:
  # This is a path to a file inside the dashboards directory inside the chart directory
  file: dashboards/custom-dashboard.json**
@maorfr

This comment has been minimized.

Copy link
Member

@maorfr maorfr commented Apr 2, 2019

can you check the latest chart version?

@petrokashlikov

This comment has been minimized.

Copy link
Author

@petrokashlikov petrokashlikov commented Apr 2, 2019

@maorfr just tried, same situation. File is mounted empty in container.
If I insert the same dashboard json content with this key json: | directly in values.yaml then it works for example...

@maorfr

This comment has been minimized.

Copy link
Member

@maorfr maorfr commented Apr 2, 2019

Can you verify that the chart version is 3.0.1?

@petrokashlikov

This comment has been minimized.

Copy link
Author

@petrokashlikov petrokashlikov commented Apr 2, 2019

Yes, it is. Here is for example output for dashboard ConfigMap, which was generated during chart install

apiVersion: v1
kind: ConfigMap
metadata:
name: grafana-dashboards-default
labels:
app: grafana
chart: grafana-3.0.1
release: grafana
heritage: Tiller
dashboard-provider: default
data:
redis.json:
""

@petrokashlikov

This comment has been minimized.

Copy link
Author

@petrokashlikov petrokashlikov commented Apr 2, 2019

I've discovered some interesting behaviour:

If I run like this:

helm install  --dry-run --debug --name grafana --namespace monitoring -f values.yaml stable/grafana
[debug] Created tunnel using local port: '64644'
[debug] SERVER: "127.0.0.1:64644"
[debug] Original chart version: ""
[debug] Fetched stable/grafana to /Users/petro.kashlikov/.helm/cache/archive/grafana-3.0.1.tgz
[debug] CHART PATH: /Users/petro.kashlikov/.helm/cache/archive/grafana-3.0.1.tgz

Then file is not processed as previously described.

When I did
helm fetch stable/grafana --untar
and then run
helm install --dry-run --debug --name grafana --namespace monitoring -f values.yaml .
then file is processing.

@maorfr

This comment has been minimized.

Copy link
Member

@maorfr maorfr commented Apr 2, 2019

The file has to be inside the dashboards dir. It is not a feature that works for helm install. Does this make sense?

@petrokashlikov

This comment has been minimized.

Copy link
Author

@petrokashlikov petrokashlikov commented Apr 2, 2019

The file has to be inside the dashboards dir. It is not a feature that works for helm install. Does this make sense?

So file was inside dashboards folder in both cases. But you say if I call local chart it will pick up file and if from repo then no? Would then trick with -f /dashboards/somechart.json. work, like it works for values.yaml?

@maorfr

This comment has been minimized.

Copy link
Member

@maorfr maorfr commented Apr 2, 2019

file works locally, json works either way.

@petrokashlikov

This comment has been minimized.

Copy link
Author

@petrokashlikov petrokashlikov commented Apr 3, 2019

file works locally, json works either way.

Thank you sou much, now everything is clear and works as expected.

@petrokashlikov

This comment has been minimized.

Copy link
Author

@petrokashlikov petrokashlikov commented May 16, 2019

Hi @petrokashlikov, @maorfr,

Can you elaborate when you mention tricking "-f /dashboards/somechart.json"? Where would you specify "-f /dashboards/somechart.json"? I'm running into the same issue with the json are not being detected in the dashboards folder and I'm not using the chart folder. I just have the values.yaml and the dashboards folder. Is that suppoprted?

Also, Did you clone the grafana repository from helm/stable?

Effectively yes, it will work only if you have chart locally. You don't need to to supply this "-f /dashboards/somechart.json" it was my question.

@anton-chuhunou

This comment has been minimized.

Copy link

@anton-chuhunou anton-chuhunou commented Oct 22, 2019

This is still an issue for me. All my custom dashboards are empty in the container. Can someone please give instructions how to import dashboards?

@swarkentin

This comment has been minimized.

Copy link
Contributor

@swarkentin swarkentin commented Oct 24, 2019

@anton-chuhunou I'm seeing the issue as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.