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

Fix metric name templating and Sampling Aggregators now use Grafana Interval #76

Closed
wants to merge 19 commits into from

Conversation

jsabin
Copy link

@jsabin jsabin commented Sep 28, 2018

  • Templating variables are now resolved for the entire query.
  • Changed back to using the Grafana interval (ie. 1m, 2h) otherwise you can't use templating to specify the sampling range.
  • Fixed problem where a metric has only one tag value for a given tag but there are data points without the tag value. The UI would not let you select the tag. This was confusing for a single valued tag because it looked (from the UI) like the tag value was selected when in fact it was not.

jifwin and others added 19 commits July 10, 2018 20:39
…-templating branch from github/grafana/kairosdb-datasource repo.
…er than using a separate drop down for the value and the unit.
…but there are data points without the tag value. The UI would not let you select the tag. This was also confusing for a single valued tag because it looked (from the UI) like the tag value was selected when in fact it was not.
@gucharbon
Copy link

gucharbon commented Oct 24, 2018

Hi, I tried to test your branch but karma unit tests are not passing:

Running "karma:unit" (karma) task
24 10 2018 14:47:51.413:INFO [karma]: Karma v2.0.5 server started at http://0.0.0.0:9876/
24 10 2018 14:47:51.415:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
24 10 2018 14:47:51.418:INFO [launcher]: Starting browser PhantomJS
24 10 2018 14:47:51.780:INFO [PhantomJS 2.1.1 (Linux 0.0.0)]: Connected on socket wMfdA41YlVYi9tU7AAAA with id 14301266
................................................
PhantomJS 2.1.1 (Linux 0.0.0) TemplatingFunctionsController should resolve metrics(param) as a function FAILED
	undefined is not a function (evaluating 'expectedFunction.body.reset()')
	
	
PhantomJS 2.1.1 (Linux 0.0.0) TemplatingFunctionsController should resolve metrics(param1,param2) as a function FAILED
	Unspecified AssertionError
	AssertionError@node_modules/chai/chai.js:9320:24
	assert@node_modules/chai/chai.js:239:31
	assert@node_modules/chai/chai.js:4130:16
	
	
PhantomJS 2.1.1 (Linux 0.0.0) TemplatingFunctionsController should resolve metrics(param1, param2) as a function FAILED
	Unspecified AssertionError
	AssertionError@node_modules/chai/chai.js:9320:24
	assert@node_modules/chai/chai.js:239:31
	assert@node_modules/chai/chai.js:4130:16
	
	
PhantomJS 2.1.1 (Linux 0.0.0) TemplatingFunctionsController should resolve tag_names(metric) as a function FAILED
	undefined is not a function (evaluating 'expectedFunction.body.reset()')
	
	
PhantomJS 2.1.1 (Linux 0.0.0) TemplatingFunctionsController should resolve tag_values(metric,param2,param3) as a function FAILED
	undefined is not a function (evaluating 'expectedFunction.body.reset()')
	
	
PhantomJS 2.1.1 (Linux 0.0.0) TemplatingFunctionsController should resolve tag_values(metric, param2, param3) as a function FAILED
	Unspecified AssertionError
	AssertionError@node_modules/chai/chai.js:9320:24
	assert@node_modules/chai/chai.js:239:31
	assert@node_modules/chai/chai.js:4130:16
	
	
PhantomJS 2.1.1 (Linux 0.0.0) TemplatingFunctionsController should resolve tag_values(metric, param2, param3, filter1=$filter_variable1, filter2=$filter_variable2) as a function FAILED
	Unspecified AssertionError
	AssertionError@node_modules/chai/chai.js:9320:24
	assert@node_modules/chai/chai.js:239:31
	assert@node_modules/chai/chai.js:4130:16
	
	
....
PhantomJS 2.1.1 (Linux 0.0.0) TemplatingFunctionsController should convert single filter argument to single entry filter object FAILED
	Unspecified AssertionError
	AssertionError@node_modules/chai/chai.js:9320:24
	assert@node_modules/chai/chai.js:239:31
	assert@node_modules/chai/chai.js:4130:16
	
PhantomJS 2.1.1 (Linux 0.0.0) TemplatingFunctionsController should convert single filter argument with prefix and suffix to single entry filter object FAILED
	Unspecified AssertionError
	AssertionError@node_modules/chai/chai.js:9320:24
	assert@node_modules/chai/chai.js:239:31
	assert@node_modules/chai/chai.js:4130:16
	
PhantomJS 2.1.1 (Linux 0.0.0) TemplatingFunctionsController should convert multiple filter arguments to multiple entries filter object FAILED
	Unspecified AssertionError
	AssertionError@node_modules/chai/chai.js:9320:24
	assert@node_modules/chai/chai.js:239:31
	assert@node_modules/chai/chai.js:4130:16
	
......................................................
PhantomJS 2.1.1 (Linux 0.0.0) LegacyTargetConverter alias convert aggregators properly FAILED
	expected [ Array(1) ] to deeply equal [ Array(1) ]
	AssertionError@node_modules/chai/chai.js:9320:24
	assert@node_modules/chai/chai.js:239:31
	assertEql@node_modules/chai/chai.js:1441:16
	methodWrapper@node_modules/chai/chai.js:7709:30
	assertEqual@node_modules/chai/chai.js:1381:22
	methodWrapper@node_modules/chai/chai.js:7709:30
	
PhantomJS 2.1.1 (Linux 0.0.0): Executed 117 of 117 (11 FAILED) (0.078 secs / 0.043 secs)
Warning: Task "karma:unit" failed.� Use --force to continue.

Aborted due to warnings.
The command '/bin/sh -c apt-get update && apt-get -y install --no-install-recommends gnupg2 apt-transport-https lsb-release bzip2 git wget &&     wget -qO- https://deb.nodesource.com/setup_8.x | bash - &&     apt-get install -y --no-install-recommends nodejs &&     cd $GF_PATHS_PLUGINS &&     git clone --single-branch -b ${KAIROS_DATASOURCE_BRANCH} ${KAIROS_DATASOURCE_REPO} &&     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/*' returned a non-zero code: 3
ERROR: Job failed: exit code 3

I'm using Docker and here is my Dockerfile:

ARG GRAFANA_VERSION="5.3.1"

FROM grafana/grafana:${GRAFANA_VERSION} as base_image

ARG KAIROS_DATASOURCE_BRANCH="fix-metric-name-templating"
ARG KAIROS_DATASOURCE_REPO="https://github.com/ppbizapps/kairosdb-datasource"

USER root

RUN apt-get update && apt-get -y install --no-install-recommends gnupg2 apt-transport-https lsb-release bzip2 git wget && \
    wget -qO- https://deb.nodesource.com/setup_8.x | bash - && \
    apt-get install -y --no-install-recommends nodejs && \
    cd $GF_PATHS_PLUGINS && \
    git clone --single-branch -b ${KAIROS_DATASOURCE_BRANCH} ${KAIROS_DATASOURCE_REPO} && \
    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

FROM base_image

USER root

COPY grafana/dashboards /var/lib/grafana/dashboards
COPY grafana/provisioning/datasource_provider.yml  /etc/grafana/provisioning/datasources/datasource_provider.yml
COPY grafana/provisioning/dashboard_provider.yml /etc/grafana/provisioning/dashboards/dashboard_provider.yml
COPY grafana/provisioning/ldap.toml /etc/grafana/ldap.toml

USER grafana

ENV GF_AUTH_LDAP_ENABLED=true

I didn't specify build args when running docker build so default values are used.

Build is automated with gitlab-ci:

image: docker:latest

services:
  - name: docker:dind

variables:
  PROJECT_NAME: myproject
  PROJECT_REGISTRY: myregistry

stages:
  - build_docker

build_docker_image_grafana_5.3.1_pull_request_76:
  image: docker:dind
  stage: build_docker
  script:
    - apk add --update bash
    - docker build -t "${PROJECT_NAME}:pull_request_76" -f docker/Dockerfile_pull_request_76 .
    - docker tag "${PROJECT_NAME}:pull_request_76" "${PROJECT_REGISTRY}/${PROJECT_NAME}:pull_request_76"
    - docker push "${PROJECT_REGISTRY}/${PROJECT_NAME}:pull_request_76"
  tags:
    - docker

Did anyone face the same issue ?

@jsabin
Copy link
Author

jsabin commented Nov 13, 2018

The fork was not clean. Killing this and creating a new pull request.

@jsabin jsabin closed this Nov 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants