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

Add support for offset parameter in Elasticsearch date histograms #12653

Closed
ghost opened this issue Jul 19, 2018 · 0 comments · Fixed by #14179
Closed

Add support for offset parameter in Elasticsearch date histograms #12653

ghost opened this issue Jul 19, 2018 · 0 comments · Fixed by #14179

Comments

@ghost
Copy link

ghost commented Jul 19, 2018

What Grafana version are you using?

Version 5.2.1 (commit: 2040f61)

What datasource are you using?

Elasticsearch 5.5.0

What OS are you running grafana on?

Ubuntu 16.04 Server

What did you do?

Split day interval in 8am-8am in UTC time

What was the expected result?

In CTS+0800 time,I need count doc day of day
image
The picture can count day of day(from 00:00am-00am in UTC time), I want count CTS time from 00:00am-00am(as 16pm-16pm in UTC)

What happened instead?

From elasticsearch document https://www.elastic.co/guide/en/elasticsearch/reference/5.5/search-aggregations-bucket-datehistogram-aggregation.html#offset, I can do

curl -X POST http://172.18.199.240:9200/info_data-*/_search -d '{
   "size" : 0,
   "aggs": {
      "day_of_count": {
         "date_histogram": {
            "field": "@timestamp",
            "interval": "day", 
            "offset": "-8h" 
            
         }
      }
   },
   "query": {
        "range" : {
            "@timestamp" : {
                "gte": "now-5d",
                "lte": "now"
            }
        }
    }
}'

Response:

{
	"took": 18,
	"timed_out": false,
	"_shards": {
		"total": 245,
		"successful": 245,
		"failed": 0
	},
	"hits": {
		"total": 267097,
		"max_score": 0.0,
		"hits": []
	},
	"aggregations": {
		"day_of_count": {
			"buckets": [{
				"key_as_string": "2018-07-13T16:00:00.000Z",
				"key": 1531497600000,
				"doc_count": 17337
			}, {
				"key_as_string": "2018-07-14T16:00:00.000Z",
				"key": 1531584000000,
				"doc_count": 53230
			}, {
				"key_as_string": "2018-07-15T16:00:00.000Z",
				"key": 1531670400000,
				"doc_count": 53922
			}, {
				"key_as_string": "2018-07-16T16:00:00.000Z",
				"key": 1531756800000,
				"doc_count": 53485
			}, {
				"key_as_string": "2018-07-17T16:00:00.000Z",
				"key": 1531843200000,
				"doc_count": 53497
			}, {
				"key_as_string": "2018-07-18T16:00:00.000Z",
				"key": 1531929600000,
				"doc_count": 35626
			}]
		}
	}
}

But I cannot set offset in Grafana? Can and the features or someone tell how can set offset, Thanks

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.

@torkelo torkelo changed the title Cannot set date_histogram offset use elasticsearch as datasource Add support for offset parameter in Elasticsearch date histograms Jul 19, 2018
mattiarossi added a commit to mattiarossi/grafana that referenced this issue Nov 24, 2018
@marefr marefr added this to the 5.5 milestone Dec 3, 2018
marefr added a commit that referenced this issue Dec 3, 2018
ryantxu added a commit to ryantxu/grafana that referenced this issue Dec 3, 2018
* grafana/master: (39 commits)
  update package.json to next version
  changelog: add notes about closing grafana#13815
  changelog: add notes about closing grafana#14246
  changelog: add notes about closing grafana#12653
  Hid "Forgot your password" link from login menu when reset is disabled
  Prevent password reset when login form is disabled or either LDAP or Auth Proxy is enabled
  update changelog
  update latest.json to latest stable version
  new stable docs version
  dataproxy: Override incoming Authorization header
  changelog: add notes about closing grafana#14228
  Explore: Show logging errors from backend
  change obj order when merging so that correct format is being used
  Explore: Fix logging query parser for regex with quantifiers
  Update README.md
  Fixed typo in function name
  Explore: Fix label and history suggestions
  let each sql datasource handle timeFrom and timeTo macros
  Review feedback
  changelog: add notes about closing grafana#14167
  ...
@torkelo torkelo modified the milestones: 5.5, 6.0-beta1 Jan 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants