#Hi seems the grafana tool released in 22

1 messages · Page 1 of 1 (latest)

wooden zodiac
#

hi @haughty dirge I bet I know what's happening - it wasn't bin/grafana that changed, but the dashboards. Let me check. The dashboards changed so that uid was blank "uid": "", that way when Grafana imports them it assigns a new one. Sounds like that broke you

haughty dirge
#

we are restoring from json files exported by grafana tool and they have UIDs. when importing, the UIDs are replaced. We import them to a blank grafana instance

wooden zodiac
#

when Grafana imports dashboards with blank uid, Grafana creates a uid. Then when exported, it will have a uid - are you modifying the dashboards and that is why you want to export and reimport in another instance of grafana?

haughty dirge
#

some background info 😀 we run grafan in K8s without persistent storage. Every pod restart we lose all our dashboards. So we set up a cron job to back up everyday using garfana tool

#

after grafana pod is restart we use grafana to to import from backup

#

we used to use grafana tool in 21.08 release and it restored without lossing the uids

#

today i tried to upgrade to 22.11 and the restored dashboards all have new uid

#

downgrade to 21.08 and restore worked fine

wooden zodiac
#

makes sense - and you are modifying the dashboards and want those changes exported and then reimported on pod restart? Can you paste the command you're using to do the restore?

#

the other challenge with that workflow is that you'll miss the many many bug fixes we've made to dashboards between 21.08 and 22.11

#

since you're trying to use 21.08 dashboards in 22.11

haughty dirge
#

no. we use 21.08 only for it's grafana tool on a linux box. All dashbords are updated regularly in K8s

#

we are on harvest 22.08 😀

#

here is the back up part

      do
        echo n |  /opt/harvest/bin/grafana export --config /opt/harvest/harvest.yml -k -a https://$HOST -d $dir/$f -t $GRAFANA_TOKEN -f $f
        # remove "id" from json files or restore will fail (grafana will try updating if id is present. but we are restoring to an empty instance)
        cd $dir/"$f"
        for i in `ls *json`; do jq 'del(.id)' $i > $i.tmp && mv $i.tmp $i; done
      done
wooden zodiac
haughty dirge
#

restore

      for x in $(ls -d *)
      do
        echo n |  /opt/harvest/bin/grafana import --config /opt/harvest/harvest.yml -k -a https://$HOST -d $x -t $GRAFANA_TOKEN -f $x
      done
#

first i thought it may caused by the "-o". but without "-o", it still replaces uuid

wooden zodiac
#

let me see if I can reproduce locally with 22.11

wooden zodiac
#

reproduced - bin/grafana changed in Feb 2022, import replaces uid and id with empty string so Grafana assigns new ones on import.

That was done so importing doesn't overwrite existing dashboards that customers may have modified. When uid and id are not emptied, Grafana overwrites existing dashboards, regardless of what folder they are in. Not overwriting existing dashboards is crucial. In your case though, clearing uid and id causes Grafana to assign a new uid thus breaking your links. That's especially annoying since there is nothing to overwrite in your case 🙂 Perhaps the simple solution is to change bin/grafana import to not empty the uid/id when you pass --overwrite. Let me make that change and make sure it works for your usecase

haughty dirge
#

Thanks!

wooden zodiac
haughty dirge
#

Will try tomorrow. Thanks a lot!

haughty dirge
#

Downloaded the nightly, but did not work.

harvest version 22.11.29-nightly (commit 67fe464f) (build date 2022-11-29T00:22:29-0500) linux/amd64
#

from the timestamp maybe i should wait?

wooden zodiac
#

that's right, that change has not hit nightly yet since it wasn't committed until this morning. Let me kick one off for you

wooden zodiac
#

nightly is published

haughty dirge
#

downloading

haughty dirge
#

it works if i import to an empty Grafana. But it won't overwrite existing dashboards. i was lazy and tried to fix the links by import from backup.😀

wooden zodiac
#

sounds like that solves your original ask, is that right? When you say it won't overwrite existing dashboards, do you mean the uid is the same but the dashboard changes or the dashboard doesn't change or something else?

haughty dirge
#

yes it did solve my original problem.

#

when i first tried, i had a grafana with "wrong" uids that caused broken links. without destroying the pod and get an empty grafana, i imported dashboards hoping it would overwrite with the uids from backup json files. but after importing the dashboards did not have the uids from backup json files. actually i am not sure if they were overwritten with new ones or kept old.

#

just still not sure what the "overwrite" behavior is

wooden zodiac
#

right! so for your original problem of empty grafana, overwrite will use the exported uids and everything will work as you want. In the case of already imported dashboards, overwrite is not doing what you expect because the original uid is retained. There is no workaround for that - Grafana does import the new dashboard with changes, creates a new version (visible in the version tab), but Grafana will retain the old uid. I don't know of a way to overwrite that

haughty dirge
#

so without overwrite option, the import process will skip existing dashboards ?

wooden zodiac
#

without overwrite bin/grafana will refuse to import like so

haughty dirge
#

got it. i thought "overwrite" was to replace the dashboard with exact the json file to be imported😀

#

maybe better explained in the error message with --overwrite will import but with a new version number

wooden zodiac
#

good idea, we'll do that

haughty dirge
#

Thank you very much for all the help!

wooden zodiac
#

you bet!