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

Cannot read property 'templateSrv' of undefined #11904

Closed
sanel opened this issue May 10, 2018 · 18 comments · Fixed by #12673
Closed

Cannot read property 'templateSrv' of undefined #11904

sanel opened this issue May 10, 2018 · 18 comments · Fixed by #12673
Labels
area/datasource datasource/OpenTSDB needs more info Issue needs more information, like query results, dashboard or panel json, grafana version etc
Milestone

Comments

@sanel
Copy link

sanel commented May 10, 2018

Hi,

I started to get above error, after updating Grafana to 5.1.x. Details are below.

What Grafana version are you using?

5.1.2

What datasource are you using?

OpenTSDB

What OS are you running grafana on?

CentOS 7.4

What did you do?

Upgraded Grafana from 5.0.x to 5.1.

What was the expected result?

Dashboards should show metrics, just as in 5.0.x versions.

What happened instead?

Some dashboards started to report: Cannot read property 'templateSrv' of undefined without showing any metrics. Here is stacktrace from js console:

Panel data error: TypeError: Cannot read property 'templateSrv' of undefined
    at query_ctrl.ts:5
    at lodash.js:2852
    at lodash.js:4944
    at dr (lodash.js:3001)
    at lodash.js:4913
    at ur (lodash.js:2851)
    at Function.as [as every] (lodash.js:9148)
    at query_ctrl.ts:3
    at A (lodash.js:823)
    at Function.fa [as findIndex] (lodash.js:7275)

If related to metric query / data viz:

Include raw network request & response: get by opening Chrome Dev Tools (F12, Ctrl+Shift+I on windows, Cmd+Opt+I on Mac), go the network tab.

Here is example from Query Inspector for one of the metrics:

{
  "xhrStatus": "complete",
  "request": {
    "method": "POST",
    "url": "api/datasources/proxy/5/api/query",
    "data": {
      "start": 1525952197814,
      "queries": [
        {
          "metric": "cpu-0/cpu-idle",
          "aggregator": "sum",
          "downsample": "1s-avg",
          "tags": {
            "host": "metis"
          }
        },
        {
          "metric": "cpu-0/cpu-interrupt",
          "aggregator": "sum",
          "downsample": "1s-avg"
        },
        {
          "metric": "cpu-0/cpu-nice",
          "aggregator": "sum",
          "downsample": "1s-avg"
        }
      ],
      "msResolution": false,
      "globalAnnotations": true
    }
  },
  "response": [
    {
      "metric": "cpu-0/cpu-idle",
      "tags": {
        "host": "metis"
      },
      "aggregateTags": [],
      "dps": {
        "1525952198": 72.19999694824219,
        "1525952208": 89.20001220703125,
        "1525952218": 89.8000717163086,
        "1525952228": 83.09960174560547,
        "1525952238": 77.69925689697266,
        "1525952248": 76.50093078613281,
        "1525952258": 74.30047607421875,
        "1525952268": 74.49960327148438,
        "1525952278": 84.39971160888672,
        "1525952288": 78.00022888183594,
        "1525952298": 66.39998626708984,
        "1525952308": 69.60054016113281,
        "1525952318": 78.69945526123047,
        "1525952328": 76.20018768310547,
        "1525952338": 77.099609375,
        "1525952348": 56.099971771240234,
        "1525952358": 69.90052795410156,
        "1525952368": 77.9996109008789,
        "1525952378": 71.6000747680664,
        "1525952388": 74.39996337890625,
        "1525952398": 74.89987182617188,
        "1525952408": 65.99996185302734,
        "1525952418": 73.19950103759766,
        "1525952428": 78.40068817138672,
        "1525952438": 72.49996185302734,
        "1525952448": 79.29962158203125,
        "1525952458": 78.50043487548828,
        "1525952468": 67.99994659423828,
        "1525952478": 77.9001693725586,
        "1525952488": 59.99985885620117,
        "1525952498": 73.0001220703125,
        "1525952508": 77.99980163574219,
        "1525952518": 67.79724884033203,
        "1525952528": 81.80354309082031,
        "1525952538": 74.09959411621094,
        "1525952548": 76.00048065185547,
        "1525952558": 71.19967651367188,
        "1525952568": 75.1001205444336,
        "1525952578": 79.89675903320312,
        "1525952588": 81.6033706665039,
        "1525952598": 70.19974517822266,
        "1525952608": 71.60009765625,
        "1525952618": 74.30049133300781,
        "1525952628": 78.19928741455078,
        "1525952638": 74.00082397460938,
        "1525952648": 78.5994873046875,
        "1525952658": 77.99995422363281,
        "1525952668": 77.09991455078125,
        "1525952678": 84.09981536865234,
        "1525952688": 75.89991760253906,
        "1525952698": 67.30049133300781,
        "1525952708": 54.99971008300781,
        "1525952718": 66.09981536865234,
        "1525952728": 84.20054626464844,
        "1525952738": 71.59992218017578,
        "1525952748": 66.90003967285156,
        "1525952758": 80.39990234375,
        "1525952768": 83.2001724243164,
        "1525952778": 76.79629516601562,
        "1525952788": 63.40321350097656,
        "1525952798": 72.09945678710938,
        "1525952808": 64.90032958984375,
        "1525952818": 72.89637756347656,
        "1525952828": 75.9037857055664,
        "1525952838": 64.80007934570312,
        "1525952848": 66.69928741455078,
        "1525952858": 73.8008804321289,
        "1525952868": 70.60008239746094,
        "1525952878": 61.69951248168945,
        "1525952888": 76.30021667480469,
        "1525952898": 77.50001525878906,
        "1525952908": 80.99977111816406,
        "1525952918": 84.9002914428711,
        "1525952928": 74.20014953613281,
        "1525952938": 83.89984130859375,
        "1525952948": 69.7997055053711,
        "1525952958": 74.90078735351562,
        "1525952968": 76.4995346069336,
        "1525952978": 71.99955749511719,
        "1525952988": 80.40035247802734,
        "1525952998": 80.10001373291016,
        "1525953008": 73.19972229003906,
        "1525953018": 76.10059356689453,
        "1525953028": 67.39971160888672,
        "1525953038": 82.00016021728516,
        "1525953048": 68.6000747680664,
        "1525953058": 80.49957275390625,
        "1525953068": 72.0003662109375,
        "1525953078": 81.29981231689453,
        "1525953088": 79.20006561279297,
        "1525953098": 75.19966125488281,
        "1525953108": 72.0999755859375,
        "1525953118": 52.89982986450195,
        "1525953128": 72.5006103515625,
        "1525953138": 83.00013732910156,
        "1525953148": 74.39978790283203,
        "1525953158": 85.09627532958984,
        "1525953168": 80.00360107421875,
        "1525953178": 77.29536437988281,
        "1525953188": 72.6043701171875,
        "1525953198": 83.599853515625,
        "1525953208": 83.60020446777344,
        "1525953218": 75.39995574951172,
        "1525953228": 73.697265625,
        "1525953238": 74.9030990600586,
        "1525953248": 77.39991760253906,
        "1525953258": 75.89622497558594,
        "1525953268": 66.9030990600586,
        "1525953278": 78.89989471435547,
        "1525953288": 70.49810791015625,
        "1525953298": 85.60224151611328,
        "1525953308": 67.70013427734375,
        "1525953318": 77.60002136230469,
        "1525953328": 83.59980010986328,
        "1525953338": 69.49977111816406,
        "1525953348": 69.79988098144531,
        "1525953358": 80.70062255859375,
        "1525953368": 71.799560546875,
        "1525953378": 70.09992218017578,
        "1525953388": 75.50059509277344,
        "1525953398": 82.09992980957031,
        "1525953408": 87.19973754882812,
        "1525953418": 90.50025177001953,
        "1525953428": 65.4996566772461,
        "1525953438": 77.60044860839844,
        "1525953448": 69.10002136230469,
        "1525953458": 79.69947814941406,
        "1525953468": 79.80010223388672,
        "1525953478": 75.1001968383789,
        "1525953488": 82.59611511230469,
        "1525953498": 71.2033920288086,
        "1525953508": 81.40009307861328,
        "1525953518": 86.89986419677734,
        "1525953528": 71.90013122558594,
        "1525953538": 74.398681640625,
        "1525953548": 69.00111389160156,
        "1525953558": 81.796142578125,
        "1525953568": 80.50387573242188,
        "1525953578": 84.99981689453125,
        "1525953588": 89.80005645751953,
        "1525953598": 85.69979858398438,
        "1525953608": 72.5966796875,
        "1525953618": 69.70355224609375,
        "1525953628": 63.49998474121094,
        "1525953638": 49.59995651245117,
        "1525953648": 1.0999994277954102,
        "1525953658": 52.19978332519531,
        "1525953668": 74.10022735595703,
        "1525953678": 80.30013275146484,
        "1525953688": 79.10009765625,
        "1525953698": 82.89815521240234,
        "1525953708": 84.5013198852539,
        "1525953718": 86.2965087890625,
        "1525953728": 84.2037582397461,
        "1525953738": 84.80010986328125,
        "1525953748": 84.3956298828125,
        "1525953758": 80.60425567626953,
        "1525953768": 73.99946594238281,
        "1525953778": 69.00045013427734,
        "1525953788": 77.99961853027344,
        "1525953798": 61.30023193359375,
        "1525953808": 69.4000473022461,
        "1525953818": 84.09598541259766,
        "1525953828": 76.00364685058594,
        "1525953838": 81.6999740600586,
        "1525953848": 81.09971618652344,
        "1525953858": 75.80023193359375,
        "1525953868": 83.7995376586914,
        "1525953878": 71.69983673095703,
        "1525953888": 87.200439453125,
        "1525953898": 66.99995422363281,
        "1525953908": 71.10054779052734,
        "1525953918": 83.09976196289062,
        "1525953928": 86.19950103759766,
        "1525953938": 77.89990997314453,
        "1525953948": 65.400390625,
        "1525953958": 66.59993743896484,
        "1525953968": 75.39678192138672,
        "1525953978": 80.09857940673828,
        "1525953988": 80.60503387451172
      }
    },
    {
      "metric": "cpu-0/cpu-interrupt",
      "tags": {
        "host": "metis"
      },
      "aggregateTags": [],
      "dps": {
        "1525952198": 0,
        "1525952208": 0,
        "1525952218": 0,
        "1525952228": 0,
        "1525952238": 0,
        "1525952248": 0,
        "1525952258": 0,
        "1525952268": 0,
        "1525952278": 0,
        "1525952288": 0,
        "1525952298": 0,
        "1525952308": 0,
        "1525952318": 0,
        "1525952328": 0,
        "1525952338": 0,
        "1525952348": 0,
        "1525952358": 0,
        "1525952368": 0,
        "1525952378": 0,
        "1525952388": 0,
        "1525952398": 0,
        "1525952408": 0,
        "1525952418": 0,
        "1525952428": 0,
        "1525952438": 0,
        "1525952448": 0,
        "1525952458": 0,
        "1525952468": 0,
        "1525952478": 0,
        "1525952488": 0,
        "1525952498": 0,
        "1525952508": 0,
        "1525952518": 0,
        "1525952528": 0,
        "1525952538": 0,
        "1525952548": 0,
        "1525952558": 0,
        "1525952568": 0,
        "1525952578": 0,
        "1525952588": 0,
        "1525952598": 0,
        "1525952608": 0,
        "1525952618": 0,
        "1525952628": 0,
        "1525952638": 0,
        "1525952648": 0,
        "1525952658": 0,
        "1525952668": 0,
        "1525952678": 0,
        "1525952688": 0,
        "1525952698": 0,
        "1525952708": 0,
        "1525952718": 0,
        "1525952728": 0,
        "1525952738": 0,
        "1525952748": 0,
        "1525952758": 0,
        "1525952768": 0,
        "1525952778": 0,
        "1525952788": 0,
        "1525952798": 0,
        "1525952808": 0,
        "1525952818": 0,
        "1525952828": 0,
        "1525952838": 0,
        "1525952848": 0,
        "1525952858": 0,
        "1525952868": 0,
        "1525952878": 0,
        "1525952888": 0,
        "1525952898": 0,
        "1525952908": 0,
        "1525952918": 0,
        "1525952928": 0,
        "1525952938": 0,
        "1525952948": 0,
        "1525952958": 0,
        "1525952968": 0,
        "1525952978": 0,
        "1525952988": 0,
        "1525952998": 0,
        "1525953008": 0,
        "1525953018": 0,
        "1525953028": 0,
        "1525953038": 0,
        "1525953048": 0,
        "1525953058": 0,
        "1525953068": 0,
        "1525953078": 0,
        "1525953088": 0,
        "1525953098": 0,
        "1525953108": 0,
        "1525953118": 0,
        "1525953128": 0,
        "1525953138": 0,
        "1525953148": 0,
        "1525953158": 0,
        "1525953168": 0,
        "1525953178": 0,
        "1525953188": 0,
        "1525953198": 0,
        "1525953208": 0,
        "1525953218": 0,
        "1525953228": 0,
        "1525953238": 0,
        "1525953248": 0,
        "1525953258": 0,
        "1525953268": 0,
        "1525953278": 0,
        "1525953288": 0,
        "1525953298": 0,
        "1525953308": 0,
        "1525953318": 0,
        "1525953328": 0,
        "1525953338": 0,
        "1525953348": 0,
        "1525953358": 0,
        "1525953368": 0,
        "1525953378": 0,
        "1525953388": 0,
        "1525953398": 0,
        "1525953408": 0,
        "1525953418": 0,
        "1525953428": 0,
        "1525953438": 0,
        "1525953448": 0,
        "1525953458": 0,
        "1525953468": 0,
        "1525953478": 0,
        "1525953488": 0,
        "1525953498": 0,
        "1525953508": 0,
        "1525953518": 0,
        "1525953528": 0,
        "1525953538": 0,
        "1525953548": 0,
        "1525953558": 0,
        "1525953568": 0,
        "1525953578": 0,
        "1525953588": 0,
        "1525953598": 0,
        "1525953608": 0,
        "1525953618": 0,
        "1525953628": 0,
        "1525953638": 0,
        "1525953648": 0,
        "1525953658": 0,
        "1525953668": 0,
        "1525953678": 0,
        "1525953688": 0,
        "1525953698": 0,
        "1525953708": 0,
        "1525953718": 0,
        "1525953728": 0,
        "1525953738": 0,
        "1525953748": 0,
        "1525953758": 0,
        "1525953768": 0,
        "1525953778": 0,
        "1525953788": 0,
        "1525953798": 0,
        "1525953808": 0,
        "1525953818": 0,
        "1525953828": 0,
        "1525953838": 0,
        "1525953848": 0,
        "1525953858": 0,
        "1525953868": 0,
        "1525953878": 0,
        "1525953888": 0,
        "1525953898": 0,
        "1525953908": 0,
        "1525953918": 0,
        "1525953928": 0,
        "1525953938": 0,
        "1525953948": 0,
        "1525953958": 0.09999994933605194,
        "1525953968": 0,
        "1525953978": 0,
        "1525953988": 0
      }
    },
    {
      "metric": "cpu-0/cpu-nice",
      "tags": {
        "host": "metis"
      },
      "aggregateTags": [],
      "dps": {
        "1525952198": 0,
        "1525952208": 0,
        "1525952218": 0,
        "1525952228": 0,
        "1525952238": 0,
        "1525952248": 0,
        "1525952258": 0,
        "1525952268": 0,
        "1525952278": 0,
        "1525952288": 0,
        "1525952298": 0,
        "1525952308": 0,
        "1525952318": 0,
        "1525952328": 0,
        "1525952338": 0,
        "1525952348": 0,
        "1525952358": 0,
        "1525952368": 0,
        "1525952378": 0,
        "1525952388": 0,
        "1525952398": 0,
        "1525952408": 0,
        "1525952418": 0,
        "1525952428": 0,
        "1525952438": 0,
        "1525952448": 0,
        "1525952458": 0,
        "1525952468": 0,
        "1525952478": 0,
        "1525952488": 0,
        "1525952498": 0,
        "1525952508": 0,
        "1525952518": 0,
        "1525952528": 0,
        "1525952538": 0,
        "1525952548": 0,
        "1525952558": 0,
        "1525952568": 0,
        "1525952578": 0,
        "1525952588": 0,
        "1525952598": 0,
        "1525952608": 0,
        "1525952618": 0,
        "1525952628": 0,
        "1525952638": 0,
        "1525952648": 0,
        "1525952658": 0,
        "1525952668": 0,
        "1525952678": 0,
        "1525952688": 0,
        "1525952698": 0,
        "1525952708": 0,
        "1525952718": 0,
        "1525952728": 0,
        "1525952738": 0,
        "1525952748": 0,
        "1525952758": 0,
        "1525952768": 0,
        "1525952778": 0,
        "1525952788": 0,
        "1525952798": 0,
        "1525952808": 0,
        "1525952818": 0,
        "1525952828": 0,
        "1525952838": 0,
        "1525952848": 0,
        "1525952858": 0,
        "1525952868": 0,
        "1525952878": 0,
        "1525952888": 0,
        "1525952898": 0,
        "1525952908": 0,
        "1525952918": 0,
        "1525952928": 0,
        "1525952938": 0,
        "1525952948": 0,
        "1525952958": 0,
        "1525952968": 0,
        "1525952978": 0,
        "1525952988": 0,
        "1525952998": 0,
        "1525953008": 0,
        "1525953018": 0,
        "1525953028": 0,
        "1525953038": 0,
        "1525953048": 0,
        "1525953058": 0,
        "1525953068": 0,
        "1525953078": 0,
        "1525953088": 0,
        "1525953098": 0,
        "1525953108": 0,
        "1525953118": 0,
        "1525953128": 0,
        "1525953138": 0,
        "1525953148": 0,
        "1525953158": 0,
        "1525953168": 0,
        "1525953178": 0,
        "1525953188": 0,
        "1525953198": 0,
        "1525953208": 0,
        "1525953218": 0,
        "1525953228": 0,
        "1525953238": 0,
        "1525953248": 0,
        "1525953258": 0,
        "1525953268": 0,
        "1525953278": 0,
        "1525953288": 0,
        "1525953298": 0,
        "1525953308": 0,
        "1525953318": 0,
        "1525953328": 0,
        "1525953338": 0,
        "1525953348": 0,
        "1525953358": 0,
        "1525953368": 0,
        "1525953378": 0,
        "1525953388": 0,
        "1525953398": 0,
        "1525953408": 0,
        "1525953418": 0,
        "1525953428": 0,
        "1525953438": 0,
        "1525953448": 0,
        "1525953458": 0,
        "1525953468": 0,
        "1525953478": 0,
        "1525953488": 0,
        "1525953498": 0,
        "1525953508": 0,
        "1525953518": 0,
        "1525953528": 0,
        "1525953538": 0,
        "1525953548": 0,
        "1525953558": 0,
        "1525953568": 0,
        "1525953578": 0,
        "1525953588": 0,
        "1525953598": 0,
        "1525953608": 0,
        "1525953618": 0,
        "1525953628": 0,
        "1525953638": 0,
        "1525953648": 0,
        "1525953658": 0,
        "1525953668": 0,
        "1525953678": 0,
        "1525953688": 0,
        "1525953698": 0,
        "1525953708": 0,
        "1525953718": 0,
        "1525953728": 0,
        "1525953738": 0,
        "1525953748": 0,
        "1525953758": 0,
        "1525953768": 0,
        "1525953778": 0,
        "1525953788": 0,
        "1525953798": 0,
        "1525953808": 0,
        "1525953818": 0,
        "1525953828": 0,
        "1525953838": 0,
        "1525953848": 0,
        "1525953858": 0,
        "1525953868": 0,
        "1525953878": 0,
        "1525953888": 0,
        "1525953898": 0,
        "1525953908": 0,
        "1525953918": 0,
        "1525953928": 0,
        "1525953938": 0,
        "1525953948": 0,
        "1525953958": 0,
        "1525953968": 0,
        "1525953978": 0,
        "1525953988": 0
      }
    }
  ]
}
@daniellee
Copy link
Contributor

I can't reproduce this - I tested OpenTSDB on 5.1.2 and in the latest master.

The error is from the query controller which is the code for the query editor (the metrics tab). And templateSrv is not used in the OpenTSDB query controller. Can the error be from another panel or datasource?

@daniellee daniellee added the needs more info Issue needs more information, like query results, dashboard or panel json, grafana version etc label May 14, 2018
@sanel
Copy link
Author

sanel commented May 14, 2018

Hi @daniellee,

Thanks for response. Just noticed that stacktrace is missing crucial part - here is updated version:

Panel data error: TypeError: Cannot read property 'templateSrv' of undefined
  metrics_panel_ctrl.ts:160 
    at query_ctrl.ts:5
    at lodash.js:2852
    at lodash.js:4944
    at dr (lodash.js:3001)
    at lodash.js:4913
    at ur (lodash.js:2851)
    at Function.as [as every] (lodash.js:9148)
    at query_ctrl.ts:3
    at A (lodash.js:823)
    at Function.fa [as findIndex] (lodash.js:7275)

It actually points to metrics_panel controller, specifically this part I guess:

 calculateInterval() {
    var intervalOverride = this.panel.interval;

    // if no panel interval check datasource
    if (intervalOverride) {
>>   intervalOverride = this.templateSrv.replace(intervalOverride, this.panel.scopedVars);
    } else if (this.datasource && this.datasource.interval) {
      intervalOverride = this.datasource.interval;
    }

    var res = kbn.calculateInterval(this.range, this.resolution, intervalOverride);
    this.interval = res.interval;
    this.intervalMs = res.intervalMs;
  }

Can the error be from another panel or datasource?

No. I do have zabbix-grafana plugin installed, but this dashboard is exclusively using OpenTSDB, with datasource version set to version == 2.2 and resolution set to second.

@sanel
Copy link
Author

sanel commented May 14, 2018

Also to add: downgrading to 5.1.0 version of Grafana, produces the same error as above. Downgrading to 5.0.4, things are working fine.

@daniellee
Copy link
Contributor

Have you got a dashboard (the dashboard json) that does not contain anything sensitive that you can share? I can not recreate this and I don't see any recent changes in the code that could cause this error.

The calculateInterval method is internal to the MetricsPanelCtrl and is only triggered when the dashboard is refreshed. If there was an error there then it would affect every datasource not just OpenTSDB.

Also, which browser are you using (just to double check that it is not specific to one browser)?

@degremont
Copy link

degremont commented May 15, 2018

I've got a very similar problem.
I'm upgrading to the same Grafana version (5.1.2), coming from 4.9.

I'm using OpenTSDB as backend. I've several of them. OpenTSDB 2.3 works fine, OpenTSDB 2.0 triggers a JS error. (Same CentOS 7.4)

The only difference is the error message type is undefined in mapMetricsToTargets.

I've downgraded to Grafana 5.0.4 and it works fine.

I confirm there is a real bug with Grafana 5.1 and OpenTSDB 2.0 or 2.1

@sanel
Copy link
Author

sanel commented May 15, 2018

@daniellee here is json from dashboard, with three panels (cpu, memory and swap), where all of three are failing.

@degremont I'd add it fails with OpenTSDB 2.2 too.

grafana.json.gz

@daniellee
Copy link
Contributor

@degremont do you have a full stack trace for your error?

@degremont
Copy link

@daniellee I can't copy paste the stacktrace unfortunately. Anyway it is very cumbersome, refering to internal JS files like public/build/0.<hash>.js:...

What I could extract is:

TypeError: this is undefined
[1563]/l</t.prototype.mapMetricsToTargets/</</<@https://grafana..../public/build/0.1197ebba63...js:7:129542
ur/<@https://grafana.../public/build/vendor.0cea50118711e7e6c839.js.:1:68626
...

After analysing this minified file which seems related to buffer module from node.js, I tracked this down to call
this.templateSrv.replace(n, e.scopedVars,"pipe")

@degremont
Copy link

FYI, I've updated my OpenTSDB 2.0 cluster to OpenTSDB 2.3. I've forgetted to update the DataSource declaration in Grafana. I was still able to reproduce the problem. After I've properly set the version number, things are fine.
If I put the wrong version back, I can reproduce the problem again.

So the problem can be simply reproduced changing OpenTSDB version in Grafana DataSource.

@bobais
Copy link

bobais commented Jun 18, 2018

Hi there, I was experiencing the same issue with OpenTSDB 2.2.2 after upgrading from 5.0.4 -> 5.1.3
In the end I figure out that issue was caused by using variable in tags instead of filters.

@daniellee
Copy link
Contributor

@degremont @sanel does the comment from @bobais help?

@sanel
Copy link
Author

sanel commented Jun 20, 2018

@daniellee it helps to some point. Removing tag host = foo did remove the error, but it isn't much usable, since will not show metrics for particular host.

However, I'm not using variables in tags at all, just explicitly stating hostname.

@bobais
Copy link

bobais commented Jun 20, 2018

@sanel
well, you have to use filters instead of tags...benefit is that filters afaik are more powerful

@sanel
Copy link
Author

sanel commented Jun 20, 2018

@bobais they are powerful indeed, however, unless grafana completely removes tags support for opentsdb, they aren't working for 5.1 series as described.

@bobais
Copy link

bobais commented Jun 20, 2018

@sanel well works for me in version 5.1.3 also when using variable (mostly using literar_or, wildcard, regexp, with grouping option) on more that 30 different dashboards. I'm affraid I cannot help more.

@sanel
Copy link
Author

sanel commented Jun 20, 2018

@bobais if I'm getting you correct, in your case you have working filters with variables, but not tags?

@bobais
Copy link

bobais commented Jun 20, 2018

@sanel now yes, had similar issue with "Cannot read property 'templateSrv' of undefined" but when I changed old dashboards using tags into format where all filtering is done by filters, all works as expected.

That means where I had tag host=myserver I did remove all tags and I did add filter host literar_or myserver (and more when needed). When I wanted to break some data by tag I did choose wildcard * with selection Group by.

Anyway I would still consider this as a bug, sice tags are "only" deprecated for OpenTSDB version 2.2 but not removed. Fortunately it doesn't bother me anymore.

@dirkschneemann
Copy link

dirkschneemann commented Jul 13, 2018

I encountered the same problem with Grafana 5.2.1 in a Docker container, connected to an OpenTSDB database running version 2.2.2.

As other folks here already suggested, I could work around the issue by replacing all tags in my metrics with the according filters that do the same thing.

First of all, if you don't see the filters option in the metrics editor, make sure that your OpenTSDB data source is configured in Grafana to be at least at version 2.2, otherwise filters will not show up.

A tag like foo=bar would typically be replaced with a filter like foo = literal_or(bar) , groupBy = false . For tags that contain variables, I would use a filter like foo = wildcard(*) , groupBy = true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/datasource datasource/OpenTSDB needs more info Issue needs more information, like query results, dashboard or panel json, grafana version etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants