-
-
Save richcollier/25c9704e5df68d313c01383c5d0480ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
HOST='localhost' | |
PORT=9200 | |
JOB_ID="my_job_example" | |
ROOT="http://${HOST}:${PORT}/_ml" | |
JOBS="${ROOT}/anomaly_detectors" | |
DATAFEEDS="${ROOT}/datafeeds" | |
printf "\n== Script started for... $JOBS/$JOB_ID" | |
printf "\n\n== Creating job... \n" | |
curl -s -X PUT -H 'Content-Type: application/json' ${JOBS}/${JOB_ID}?pretty -d '{ | |
"description" : "Unusual responsetimes by airlines", | |
"analysis_config" : { | |
"bucket_span": "10m", | |
"detectors" :[{"function":"max", "field_name":"responsetime","by_field_name":"airline"}], | |
"influencers" : [ "airline" ] | |
}, | |
"data_description" : { | |
"time_field":"@timestamp", | |
"time_format": "epoch_ms" | |
} | |
}' | |
printf "\n\n== Creating datafeed... \n" | |
curl -s -X PUT -H 'Content-Type: application/json' ${DATAFEEDS}/datafeed-${JOB_ID}?pretty -d '{ | |
"job_id" : "'"$JOB_ID"'", | |
"indexes" : [ | |
"farequote-*" | |
] | |
}' | |
printf "\n\n== Opening job for ${JOB_ID}... " | |
curl -X POST ${JOBS}/${JOB_ID}/_open | |
printf "\n\n== Starting datafeed-${JOB_ID}... " | |
curl -X POST "${DATAFEEDS}/datafeed-${JOB_ID}/_start?start=1970-01-02T10:00:00Z&end=2017-02-12T00:00:00Z" | |
printf "\n\n== Finished ==\n\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment