Comments (2)
Here is example of setup Cohort plugin. Tested on Kibana 7.8.0, 7.8.1 and 7.9.0
- Set mapping what defines '@timestamp' (when doc was created, in our example order_date) and 'first_order_date' (when user/item was created for active for the first time) fields as date type,
also you can define 'dayUntilReturn' if you'll not create it as scripted field (step 3) :
PUT food_relay
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"common_id": {
"type": "keyword"
},
"dayUntilReturn": {
"type": "integer"
},
"first_order_date": {
"type": "date"
},
"order_date": {
"type": "date"
},
"order_id": {
"type": "keyword"
},
"pickup_date": {
"type": "date"
},
"pup_id": {
"type": "keyword"
},
"total_charges": {
"type": "float"
},
"user_id": {
"type": "keyword"
}
}
}
}
2- Put some cohort similar data : use _bulk file food_relay_es_bulk.csv.json
under dataset folder
POST _bulk
{"index": {"_index": "food_relay", "_id": 262}}
{"order_id": "262", "order_date": "2009-01-11", "user_id": "47", "total_charges": "50.67", "common_id": "TRQKD", "pup_id": "2", "pickup_date": "2009-01-12", "first_order_date": "2009-01-11", "dayUntilReturn": "0"}
{"index": {"_index": "food_relay", "_id": 278}}
{"order_id": "278", "order_date": "2009-01-20", "user_id": "47", "total_charges": "26.6", "common_id": "4HH2S", "pup_id": "3", "pickup_date": "2009-01-20", "first_order_date": "2009-01-11", "dayUntilReturn": "9"}
{"index": {"_index": "food_relay", "_id": 294}}
{"order_id": "294", "order_date": "2009-02-03", "user_id": "47", "total_charges": "38.71", "common_id": "3TRDC", "pup_id": "2", "pickup_date": "2009-02-04", "first_order_date": "2009-01-11", "dayUntilReturn": "23"}
{"index": {"_index": "food_relay", "_id": 301}}
{"order_id": "301", "order_date": "2009-02-06", "user_id": "47", "total_charges": "53.38", "common_id": "NGAZJ", "pup_id": "2", "pickup_date": "2009-02-09", "first_order_date": "2009-01-11", "dayUntilReturn": "26"}
{"index": {"_index": "food_relay", "_id": 302}}
3- Alternative to 'dayUntilReturn' is to create scripted field with same name and next value:
(doc['order_date'].value.toInstant().toEpochMilli() - doc['first_order_date'].value.toInstant().toEpochMilli()) / (1000 * 60 * 60* 24)
To calculate days diff on elastic side.
GET food_relay/_search
{
"_source": ["first_order_date", "order_date", "dayUntilReturn"],
"script_fields": {
"daysBetween": {
"script": {
"source": "(doc['order_date'].value.toInstant().toEpochMilli() - doc['first_order_date'].value.toInstant().toEpochMilli()) / params.factor",
"params": {
"factor": 86400000
}
}
}
}
}
4- Create new Cohort visualization, setup buckets :
- set Cohort Date bucket: Aggregation - 'Date Histogram', Field - 'first_order_date', Interval - up to you;
- set Cohort Period bucket: Sub Aggregation - 'Histogram', Field - 'dayUntilReturn', Minimum Interval - '0'
from kibana_cohort.
from kibana_cohort.
Related Issues (3)
- Kibana v7.9.0 support HOT 1
- Version for Kibana v7.12.x HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kibana_cohort.