Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.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 如何创建月度新公司条形图_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Kibana_Kibana 5 - Fatal编程技术网 elasticsearch 如何创建月度新公司条形图,elasticsearch,kibana,kibana-5,elasticsearch,Kibana,Kibana 5" /> elasticsearch 如何创建月度新公司条形图,elasticsearch,kibana,kibana-5,elasticsearch,Kibana,Kibana 5" />

elasticsearch 如何创建月度新公司条形图

elasticsearch 如何创建月度新公司条形图,elasticsearch,kibana,kibana-5,elasticsearch,Kibana,Kibana 5,假设我在elasticsearch中创建一个索引并导入数据 PUT test { "mappings": { "orders": { "properties": { "devices": { "type": "integer" }, "location": { "type":"geo_point" }, "time" : { "typ

假设我在elasticsearch中创建一个索引并导入数据

PUT test
{
  "mappings": {
    "orders": {
      "properties": {
        "devices": {
          "type": "integer"
        },
        "location": {
          "type":"geo_point"
        },
        "time" : {
          "type":"date",
          "format": "epoch_second"
        },
       "company" : {
         "type":"keyword"    
        }  
      }
    }
  }
}

在kibana要做的相当简单的事情是每月获得唯一的公司数量,这很好,但还不足以获得当月第一批订单的公司数量。这在kibana或timelion中可能吗?如果我不知道如何将数据保存到elastic以便获得此号码?我正在使用Kibana 5.1.2,我在索引中添加了一个名为sequence的属性类型,它是顺序的编号,所以如果它是第一个顺序,我给它1,如果是第二个2,依此类推。。。 映射看起来像这样

PUT test
{
  "mappings": {
    "orders": {
      "properties": {
        "devices": {
          "type": "integer"
        },
        "email": {
          "type":"keyword"
        },
        "company": {
          "type":"keyword"
        },
        "location": {
          "type":"geo_point"
        },
        "sequence":{
          "type":"integer"
        },
        "time": {
          "type":"date",
          "format": "strict_date_optional_time||epoch_second"

        }
      }
    }
  }
}
.es(q=sequence:1,index=index,timefield=time,metric=cardinality:company)
.divide(.es(index=index,timefield=time,metric=cardinality:company,offset=-1M)
.cusum()).bars()
所以对于这个操作,我选择Timelon,它很酷,可以让你计算值。新用户的MoM%公式为

 (new users this month / cumulative users till previous month) 
这是Timelon表达中的外观,如下所示

PUT test
{
  "mappings": {
    "orders": {
      "properties": {
        "devices": {
          "type": "integer"
        },
        "email": {
          "type":"keyword"
        },
        "company": {
          "type":"keyword"
        },
        "location": {
          "type":"geo_point"
        },
        "sequence":{
          "type":"integer"
        },
        "time": {
          "type":"date",
          "format": "strict_date_optional_time||epoch_second"

        }
      }
    }
  }
}
.es(q=sequence:1,index=index,timefield=time,metric=cardinality:company)
.divide(.es(index=index,timefield=time,metric=cardinality:company,offset=-1M)
.cusum()).bars()
注意,这个查询是一个完整的查询,为了便于阅读,我只把它分成3部分。我加了酒吧只是为了好玩