0

In elastic exist index

gitlab-ci-store

create POST

PUT gitlab-ci-store
{
  "mappings": {
    "properties": {
      "gitlab-ci-store": {
        "properties": {
          "project_root":  { "type": "keyword"},
          "project_name":  { "type": "keyword"},
          "template_name":  { "type": "keyword"},
          "template_version":  { "type": "keyword"},
          "template_filename":  { "type": "keyword"},
          "job_id":  { "type": "integer"},
          "timestamp":  {
            "type":   "date",
            "format": "yyyy-MM-dd HH:mm:ss"
          }
        }
    }    
    }
  }
}

query for search returns same result

GET gitlab-ci-store/_search
{
  "query": {
          "match": {
      "gitlab-ci-store.project_root": "smart_projects"
          }
  }
}

POST gitlab-ci-store/_search
{
    "query": {
       "term": {
            "gitlab-ci-store.project_root": "smart_projects"
        }
    }
}


  {
    "_index" : "gitlab-ci-store",
    "_type" : "_doc",
    "_id" : "jCbZ74MBsDU1MHfZqecN",
    "_score" : 0.13353139,
    "_source" : {
      "@timestamp" : "2022-10-19T10:46:02.764855Z",
      "gitlab-ci-store" : {
        "template_name" : "docker",
        "template_version" : "v6",
        "job_id" : 7320985,
        "project_root" : "smart_projects",
        "template_filename" : "base_docker_build",
        "project_name" : "feeds_links_kafka_listner",
        "timestamp" : "2022-10-19 01:00:00"
      }
    }
  },
  {
    "_index" : "gitlab-ci-store",
    "_type" : "_doc",
    "_id" : "CCfZ74MBsDU1MHfZ6gOU",
    "_score" : 0.13353139,
    "_source" : {
      "@timestamp" : "2022-10-19T10:46:19.539666Z",
      "gitlab-ci-store" : {
        "template_name" : "docker",
        "template_version" : "v6",
        "job_id" : 7320989,
        "project_root" : "smart_projects",
        "template_filename" : "base_docker_build",
        "project_name" : "bestsellers_uploader",
        "timestamp" : "2022-10-19 02:00:00"
      }
    }

after I connect datasource Elastic in Grafana

enter image description here

after create dashboard and add Variables, for check how work Datasource in Query option add

{"find": "fields", "type": "keyword"}

Preview of values returned norm result.

enter image description here

After add Query for returned values of gitlab-ci-store.project_name write

{"find": "terms", "field": "gitlab-ci-store.project_name", "size": 1000}

returned None

enter image description here

try else

{"find": "terms", "field": "gitlab-ci-store.project_name.string", "size": 1000}
{"find": "terms", "field": "gitlab-ci-store.project_name.keyword", "size": 1000}
{"find": "terms", "field": "gitlab-ci-store.project_name.text", "size": 1000}

same returned None

Why Grafana Variables query from data source ElasticSearch returned None?

Nikolay Baranenko
  • 1,582
  • 6
  • 35
  • 60
  • It looks like there is no terms under field gitlab-ci-store.project_name. Query is correctly written so i think there should be some problem with Elasticsearch and not Grafana. Probably i would check if ElasticSearch is decoding json field. – iamlucas Oct 21 '22 at 09:22
  • Problem solved - drop index, manual recreate index with define types (in last time I make POST curl request and all), after grafana could define variables from ELK datasource – Nikolay Baranenko Oct 24 '22 at 16:55

0 Answers0