Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
<img src="//i.stack.imgur.com/RUiNP.png" height="16" width="18" alt="" class="sponsor tag img">elasticsearch 如何比较ElasticSearch和Kibana的两个周期?_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Kibana - Fatal编程技术网 elasticsearch 如何比较ElasticSearch和Kibana的两个周期?,elasticsearch,kibana,elasticsearch,Kibana" /> elasticsearch 如何比较ElasticSearch和Kibana的两个周期?,elasticsearch,kibana,elasticsearch,Kibana" />

elasticsearch 如何比较ElasticSearch和Kibana的两个周期?

elasticsearch 如何比较ElasticSearch和Kibana的两个周期?,elasticsearch,kibana,elasticsearch,Kibana,我想在两个周期内比较相同的值,这样我就可以编写一个脚本来计算百分比差异。我的数据如下所示: { "type": "Redemption", "@timestamp": "2016-08-05T16:12:55.594909118+01:00", "points": 1109, "value": 5.545 } { "aggs" : { "points_per_week" : { "date_histogram" : {

我想在两个周期内比较相同的值,这样我就可以编写一个脚本来计算百分比差异。我的数据如下所示:

{
"type": "Redemption",
"@timestamp": "2016-08-05T16:12:55.594909118+01:00",
"points": 1109,
"value": 5.545
}
{
    "aggs" : {
        "points_per_week" : {
            "date_histogram" : {
                "field" : "@timestamp",
                "interval" : "week",
                "format" : "yyyy-MM-dd"
            },
            "aggs": {
                "total_points": {
                    "sum": {
                        "field": "points"
                    }
                },
                "points_last_week": {
                  "date_histogram" : {
                      "field" : "@timestamp",
                      "interval" : "week",
                      "format" : "yyyy-MM-dd",
                      "offset":"-1w"
                  },
                  "aggs": {
                      "total_points": {
                          "sum": {
                              "field": "points"
                          }
                      }
                  }
                }

            }

        }
    }
}
"points_per_week": {
         "buckets": [
            {
               "key_as_string": "2016-02-01",
               "key": 1454284800000,
               "doc_count": 8335,
               "total_points": {
                  "value": 12537515
               },
               "points_last_week": {
                  "buckets": [
                     {
                        "key_as_string": "2016-02-05",
                        "key": 1454630400000,
                        "doc_count": 8335,
                        "total_points": {
                           "value": 12537515
                        }
                     }
                  ]
               }
            },
我的查询如下所示:

{
"type": "Redemption",
"@timestamp": "2016-08-05T16:12:55.594909118+01:00",
"points": 1109,
"value": 5.545
}
{
    "aggs" : {
        "points_per_week" : {
            "date_histogram" : {
                "field" : "@timestamp",
                "interval" : "week",
                "format" : "yyyy-MM-dd"
            },
            "aggs": {
                "total_points": {
                    "sum": {
                        "field": "points"
                    }
                },
                "points_last_week": {
                  "date_histogram" : {
                      "field" : "@timestamp",
                      "interval" : "week",
                      "format" : "yyyy-MM-dd",
                      "offset":"-1w"
                  },
                  "aggs": {
                      "total_points": {
                          "sum": {
                              "field": "points"
                          }
                      }
                  }
                }

            }

        }
    }
}
"points_per_week": {
         "buckets": [
            {
               "key_as_string": "2016-02-01",
               "key": 1454284800000,
               "doc_count": 8335,
               "total_points": {
                  "value": 12537515
               },
               "points_last_week": {
                  "buckets": [
                     {
                        "key_as_string": "2016-02-05",
                        "key": 1454630400000,
                        "doc_count": 8335,
                        "total_points": {
                           "value": 12537515
                        }
                     }
                  ]
               }
            },
但是,结果如下所示:

{
"type": "Redemption",
"@timestamp": "2016-08-05T16:12:55.594909118+01:00",
"points": 1109,
"value": 5.545
}
{
    "aggs" : {
        "points_per_week" : {
            "date_histogram" : {
                "field" : "@timestamp",
                "interval" : "week",
                "format" : "yyyy-MM-dd"
            },
            "aggs": {
                "total_points": {
                    "sum": {
                        "field": "points"
                    }
                },
                "points_last_week": {
                  "date_histogram" : {
                      "field" : "@timestamp",
                      "interval" : "week",
                      "format" : "yyyy-MM-dd",
                      "offset":"-1w"
                  },
                  "aggs": {
                      "total_points": {
                          "sum": {
                              "field": "points"
                          }
                      }
                  }
                }

            }

        }
    }
}
"points_per_week": {
         "buckets": [
            {
               "key_as_string": "2016-02-01",
               "key": 1454284800000,
               "doc_count": 8335,
               "total_points": {
                  "value": 12537515
               },
               "points_last_week": {
                  "buckets": [
                     {
                        "key_as_string": "2016-02-05",
                        "key": 1454630400000,
                        "doc_count": 8335,
                        "total_points": {
                           "value": 12537515
                        }
                     }
                  ]
               }
            },

看起来是本周,但不是最后一周。。。有办法吗?

这是一个老问题,但以防万一有人会像我一样找到它 它可以通过以下方式实现 时间线和偏移特征

.es(offset=-1h,index=metricbeat-*, timefield='@timestamp', metric='avg:system.cpu.user.pct').label('last hour'), .es(index=metricbeat-*, timefield='@timestamp', metric='avg:system.cpu.user.pct').label('current hour')
试着看看Timelion:Kibana的时间序列作曲家