post-data.asciidoc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-post-data]]
  4. === Post data to jobs API
  5. ++++
  6. <titleabbrev>Post data to jobs</titleabbrev>
  7. ++++
  8. Sends data to an anomaly detection job for analysis.
  9. [[ml-post-data-request]]
  10. ==== {api-request-title}
  11. `POST _ml/anomaly_detectors/<job_id>/_data`
  12. [[ml-post-data-prereqs]]
  13. ==== {api-prereq-title}
  14. * If the {es} {security-features} are enabled, you must have `manage_ml` or
  15. `manage` cluster privileges to use this API. See
  16. <<security-privileges>>.
  17. [[ml-post-data-desc]]
  18. ==== {api-description-title}
  19. The job must have a state of `open` to receive and process the data.
  20. The data that you send to the job must use the JSON format. Multiple JSON
  21. documents can be sent, either adjacent with no separator in between them or
  22. whitespace separated. Newline delimited JSON (NDJSON) is a possible whitespace
  23. separated format, and for this the `Content-Type` header should be set to
  24. `application/x-ndjson`.
  25. Upload sizes are limited to the Elasticsearch HTTP receive buffer size
  26. (default 100 Mb). If your data is larger, split it into multiple chunks
  27. and upload each one separately in sequential time order. When running in
  28. real time, it is generally recommended that you perform many small uploads,
  29. rather than queueing data to upload larger files.
  30. When uploading data, check the <<ml-datacounts,job data counts>> for progress.
  31. The following records will not be processed:
  32. * Records not in chronological order and outside the latency window
  33. * Records with an invalid timestamp
  34. //TBD link to Working with Out of Order timeseries concept doc
  35. IMPORTANT: For each job, data can only be accepted from a single connection at
  36. a time. It is not currently possible to post data to multiple jobs using wildcards
  37. or a comma-separated list.
  38. [[ml-post-data-path-parms]]
  39. ==== {api-path-parms-title}
  40. `<job_id>`::
  41. (Required, string) Identifier for the job.
  42. [[ml-post-data-query-parms]]
  43. ==== {api-query-parms-title}
  44. `reset_start`::
  45. (Optional, string) Specifies the start of the bucket resetting range.
  46. `reset_end`::
  47. (Optional, string) Specifies the end of the bucket resetting range.
  48. [[ml-post-data-request-body]]
  49. ==== {api-request-body-title}
  50. A sequence of one or more JSON documents containing the data to be analyzed.
  51. Only whitespace characters are permitted in between the documents.
  52. [[ml-post-data-example]]
  53. ==== {api-examples-title}
  54. The following example posts data from the `it_ops_new_kpi.json` file to the
  55. `it_ops_new_kpi` job:
  56. [source,js]
  57. --------------------------------------------------
  58. $ curl -s -H "Content-type: application/json"
  59. -X POST http:\/\/localhost:9200/_ml/anomaly_detectors/it_ops_new_kpi/_data
  60. --data-binary @it_ops_new_kpi.json
  61. --------------------------------------------------
  62. When the data is sent, you receive information about the operational progress of
  63. the job. For example:
  64. [source,js]
  65. ----
  66. {
  67. "job_id":"it_ops_new_kpi",
  68. "processed_record_count":21435,
  69. "processed_field_count":64305,
  70. "input_bytes":2589063,
  71. "input_field_count":85740,
  72. "invalid_date_count":0,
  73. "missing_field_count":0,
  74. "out_of_order_timestamp_count":0,
  75. "empty_bucket_count":16,
  76. "sparse_bucket_count":0,
  77. "bucket_count":2165,
  78. "earliest_record_timestamp":1454020569000,
  79. "latest_record_timestamp":1455318669000,
  80. "last_data_time":1491952300658,
  81. "latest_empty_bucket_timestamp":1454541600000,
  82. "input_record_count":21435
  83. }
  84. ----
  85. For more information about these properties, see <<ml-jobstats,Job Stats>>.