Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Multi-value variable with Repeat for each value produces charts with all metrics #71

Open
gucharbon opened this issue Jul 10, 2018 · 3 comments
Assignees
Labels

Comments

@gucharbon
Copy link

gucharbon commented Jul 10, 2018

We're using Grafana to display metrics from KairosDB database.

We are using Grafana in Docker. Our Dockerfile is as follows:

ARG GRAFANA_VERSION="latest"
FROM grafana/grafana:${GRAFANA_VERSION}

ARG KAIROS_DATASOURCE_BRANCH="master"
# To use with git clone --single-branch -b ${KAIROS_DATSOURCE_BRANCH}
# --branch can also take tags and detaches the HEAD at that commit in the resulting repository.
# See https://git-scm.com/docs/git-clone

USER root

RUN apt-get update && apt-get -y install gnupg2 apt-transport-https lsb-release bzip2 && \
    curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
    apt-get install --no-install-recommends -y git nodejs && \
    cd $GF_PATHS_PLUGINS && \
    git clone --single-branch -b ${KAIROS_DATASOURCE_BRANCH} https://github.com/grafana/kairosdb-datasource && \
    cd kairosdb-datasource && \
    npm install -g grunt-cli && \
    npm install && \
    grunt && \
    apt-get --purge -y autoremove git nodejs gnupg2 bzip2 && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

USER grafana

ARG GF_INSTALL_PLUGINS="grafana-clock-panel,grafana-simple-json-datasource"

RUN if [ ! -z "${GF_INSTALL_PLUGINS}" ]; then \
    OLDIFS=$IFS; \
        IFS=','; \
    for plugin in ${GF_INSTALL_PLUGINS}; do \
        IFS=$OLDIFS; \
        grafana-cli --pluginsDir "$GF_PATHS_PLUGINS" plugins install ${plugin}; \
    done; \
fi
  • The KairosDB version we are using is KairosDB 1.2.1-1.20180331130457
  • The Grafana version we built our docker image against is Grafana v5.2.1 (2040f61)

We use variables to query metrics with regex:

image

We then created a chart panel repeating for each value of variable:

bug_grafana_kairos_chart_panel

We filled the panel Metrics options as follow:

image

When selecting only one variable, everything is working fine:

image

But when we select more than 1 metric, all metrics are displayed on all charts (and only first one uses alias)

image

I didn't use Grafana before but I'm quite sure that I saw dashboards using such features and working fine !
Can you confirm that I'm not misusing any feature ?
This issue is mentionned in How reference a multi-variable on alias #66

@jifwin
Copy link
Contributor

jifwin commented Jul 10, 2018

Hi

Thanks for the Dockerfile, it's really useful. Please check out the fix on "fix-metric-name-templating" branch. If it works for you, I'll merge it to master.

@jifwin jifwin added the bug label Jul 10, 2018
@jifwin jifwin self-assigned this Jul 10, 2018
@gucharbon
Copy link
Author

gucharbon commented Jul 11, 2018

It seems that your fix is working !

I will be templating dashboards all day long so I'll come by to you if I encounter any suspicious behavior that might have been introduced with this fix.

Thanks a lot, and do not hesitate to share this Dockerfile in the README for example. I will edit so that we have full control on which version is installed like in this build:

docker build --build-arg GRAFANA_VERSION="latest" --build-arg KAIROS_DATASOURCE_BRANCH="fix-metric-name-templating" -t grafana:kairosds-fix-metric-name-templating .

@gucharbon
Copy link
Author

Do you plan to merge the branch ?
I've been using it since you created it and it is definetly working fine.
Btw I'm still looking for a fix for Issue 67 but unfortunately I'm no JavaScript developer so it will take me some time to understand how to do that :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants