grafana-sync icon indicating copy to clipboard operation
grafana-sync copied to clipboard

cannot unmarshal number into Go struct field

Open ingvarch opened this issue 3 years ago • 22 comments

Hello,

Thank you for Grafana-sync, but I faced this issue during sync my dashboards:

2021/03/05 11:46:32 unmarshal board: json: cannot unmarshal number into Go struct field Board.panels of type string for db/kubernetes-networking-namespace-pods
2021/03/05 11:46:32 unmarshal board: json: cannot unmarshal number into Go struct field Board.panels of type string for db/kubernetes-networking-pod
2021/03/05 11:46:34 unmarshal board: json: cannot unmarshal object into Go struct field TemplateVar.templating.list.query of type string for db/loki-quick-search
2021/03/05 11:46:36 unmarshal board: json: cannot unmarshal object into Go struct field TemplateVar.templating.list.query of type string for db/services-overview

Here is a gist with dashboards https://gist.github.com/ingvarch/51ef3022738d3b9011b2ce802a605aaf

I use :

Grafana v7.4.2 (29e75ad97b) Grafana-sync - 1.1.0

ingvarch avatar Mar 05 '21 11:03 ingvarch

Hello, thank you for reporting an issue. I will check why some dashboards are not synced

mpostument avatar Mar 05 '21 12:03 mpostument

I found that if I remove grafana variables namespace and pod in loki-quick-search dashboard - I can pull this dashboard.

Screenshot 2021-03-05 at 2 31 33 PM

ingvarch avatar Mar 05 '21 12:03 ingvarch

I think that issue with fixed in the latest version of sdk. I Will try to update SDK and test

mpostument avatar Mar 05 '21 12:03 mpostument

@ingvarch can you try this version 1.1.1?

mpostument avatar Mar 05 '21 13:03 mpostument

Yes, I tried version 1.1.1 but the same problem

2021/03/05 13:27:41 unmarshal board: json: cannot unmarshal object into Go struct field TemplateVar.templating.list.query of type string for db/kubernetes-compute-resources-workload
2021/03/05 13:27:42 unmarshal board: json: cannot unmarshal number into Go struct field Board.panels of type string for db/kubernetes-networking-namespace-pods
2021/03/05 13:27:42 unmarshal board: json: cannot unmarshal number into Go struct field Board.panels of type string for db/kubernetes-networking-pod
2021/03/05 13:27:43 unmarshal board: json: cannot unmarshal object into Go struct field TemplateVar.templating.list.query of type string for db/loki-quick-search

ingvarch avatar Mar 05 '21 13:03 ingvarch

I opened issue for grafana sdk. Will try to look at it by myself once I have free time

mpostument avatar Mar 05 '21 13:03 mpostument

Hi @mpostument , i get the same Problem with one of my dashboards. How could this error be debuged? Is there a verbose oder debug function? I use :

Grafana v7.3.7 (1e261642f4) Grafana-sync - 1.2.0 2021/03/08 14:15:49 unmarshal board: json: cannot unmarshal number into Go struct field Board.panels of type string for db/aufteilung-Dashboard

SaschaBrechmannVHV avatar Mar 08 '21 13:03 SaschaBrechmannVHV

This this sdk issue. I will check if I can get additional information from sdk itself

mpostument avatar Mar 11 '21 05:03 mpostument

Hello, @mpostument

Any updates ?

ingvarch avatar May 10 '21 14:05 ingvarch

This PR was merged yesterday. Potentially it should resolve issue. Will update code late today

mpostument avatar Jun 22 '21 09:06 mpostument

Try if this version works https://github.com/mpostument/grafana-sync/releases/tag/1.4.1

mpostument avatar Jun 22 '21 17:06 mpostument

Sorry for my delay. It still doesn't work. Version 1.4.1

2021/08/11 08:36:27 unmarshal board: json: cannot unmarshal object into Go struct field TemplateVar.templating.list.query of type string for db/kubernetes-networking-workload
2021/08/11 08:36:27 unmarshal board: json: cannot unmarshal object into Go struct field TemplateVar.templating.list.query of type string for db/kubernetes-persistent-volumes
2021/08/11 08:36:27 unmarshal board: json: cannot unmarshal object into Go struct field TemplateVar.templating.list.query of type string for db/kubernetes-pods
2021/08/11 08:36:27 unmarshal board: json: cannot unmarshal object into Go struct field TemplateVar.templating.list.query of type string for db/kubernetes-statefulsets
2021/08/11 08:36:27 unmarshal board: json: cannot unmarshal object into Go struct field TemplateVar.templating.list.query of type string for db/loki-quick-search

ingvarch avatar Aug 11 '21 08:08 ingvarch

same/similar issue:

2022/06/13 16:15:19 unmarshal board: json: cannot unmarshal number into Go struct field FieldConfigCustom.fieldConfig.defaults.custom.spanNulls of type bool (panel "$deployment" of type "timeseries") for db/deployment-network-io

adamjacobmuller avatar Jun 13 '22 20:06 adamjacobmuller

Please try this version https://github.com/mpostument/grafana-sync/releases/tag/1.4.8 It includes a new version of grafana SDK which may solve this issue

mpostument avatar Jun 17 '22 14:06 mpostument

I tried the most recent 1.4.8 release and I am getting these errors:

2022/07/29 11:18:16 unmarshal board: json: cannot unmarshal object into Go struct field Target.targets.group of type []struct { Type string "json:\"type,omitempty\""; Params []string "json:\"params,omitempty\"" } (panel "Metric" of type "graph") for db/aws-cloudwatch-browser
2022/07/29 11:18:16 unmarshal board: json: cannot unmarshal object into Go struct field Target.targets.group of type []struct { Type string "json:\"type,omitempty\""; Params []string "json:\"params,omitempty\"" } (panel "CPUUtilization" of type "graph") for db/aws-ec2
2022/07/29 11:18:16 unmarshal board: json: cannot unmarshal object into Go struct field Target.targets.group of type []struct { Type string "json:\"type,omitempty\""; Params []string "json:\"params,omitempty\"" } (panel "RequestCount / Latency" of type "graph") for db/aws-elb-classic-load-balancer
2022/07/29 11:18:16 unmarshal board: json: cannot unmarshal object into Go struct field Target.targets.group of type []struct { Type string "json:\"type,omitempty\""; Params []string "json:\"params,omitempty\"" } (panel "Healthy / Unhealthy Hosts Count" of type "graph") for db/aws-network-load-balancer-nlb
2022/07/29 11:18:16 unmarshal board: json: cannot unmarshal object into Go struct field Target.targets.group of type []struct { Type string "json:\"type,omitempty\""; Params []string "json:\"params,omitempty\"" } (panel "CPUUtilization/FailedSQLServerAgentJobsCount" of type "graph") for db/aws-rds

The errors looks somewhat different so maybe progress?

sarasensible avatar Jul 29 '22 15:07 sarasensible

Aug 26 09:22:46 bastion teleport[6630]: SQLite configuration is invalid: failed to unmarshal map[data_dir:/var/lib/teleport path:/var/lib/teleport/backend sync:false] into **lite.Config, json: cannot un>
Aug 26 09:22:46 bastion teleport[6630]: "\tjson: cannot unmarshal bool into Go struct field Config.sync of type string"

config item :

  storage:
    type: sqlite
    sync: OFF

when adding quote to OFF it's working :

  storage:
    type: sqlite
    sync: "OFF"

sbourdette avatar Aug 26 '22 07:08 sbourdette

Running 1.4.10, experiencing the same issue.

aned avatar Oct 26 '22 01:10 aned

I am having a similar problem with 1.7.0:

2024/02/14 11:51:44 unmarshal board: json: cannot unmarshal string into Go struct field Target.targets.groupBy of type []string (panel "Max Memory Usage (last 15m)" of type "bargauge") for db/gitlab-runners-metrics

Here is a JSON export of the dashboard in question: gitlab-runners-metrics.json

smipi1 avatar Feb 14 '24 10:02 smipi1

similar issue with grafana-sync 1.7.0 and grafana 10.2.3

2024/02/16 11:56:31 unmarshal board: json: cannot unmarshal object into Go struct field Target.targets.groupBy of type string (panel "CPU usage/s for $instance" of type "graph") (panel "Resources" of type "row") for db/alertmanager
2024/02/16 11:56:32 unmarshal board: json: cannot unmarshal object into Go struct field Target.targets.tags of type []struct { Key string "json:\"key,omitempty\""; Operator string "json:\"operator,omitempty\""; Value string "json:\"value,omitempty\"" } (panel "Global Samples Sent by Remote" of type "timeseries") for db/prometheus-remote-storage-stats

BouchaaraAdil avatar Feb 16 '24 11:02 BouchaaraAdil

@mpostument is there a chance to take a look into my comment

https://github.com/mpostument/grafana-sync/issues/6#issuecomment-1948184832

BouchaaraAdil avatar Feb 22 '24 22:02 BouchaaraAdil

Sorry, there is no fix yet. Looks like grafana sdk is no longer developed. I don't see any PR accepted in sdk repo. Don't have fix right now

mpostument avatar Feb 24 '24 14:02 mpostument

@mpostument do you think that the grafana sdk is replaced with https://github.com/grafana/grafana-plugin-sdk-go or it's a different thing?

BouchaaraAdil avatar Mar 25 '24 11:03 BouchaaraAdil