1
0

post-data.asciidoc 3.4 KB

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