put-job.asciidoc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. --
  2. :api: put-job
  3. :request: PutJobRequest
  4. :response: PutJobResponse
  5. --
  6. [id="{upid}-{api}"]
  7. === Put {anomaly-job} API
  8. Creates a new {anomaly-job} in the cluster. The API accepts a +{request}+ object
  9. as a request and returns a +{response}+.
  10. [id="{upid}-{api}-request"]
  11. ==== Put {anomaly-job} request
  12. A +{request}+ requires the following argument:
  13. ["source","java",subs="attributes,callouts,macros"]
  14. --------------------------------------------------
  15. include-tagged::{doc-tests-file}[{api}-request]
  16. --------------------------------------------------
  17. <1> The configuration of the {anomaly-job} to create as a `Job`
  18. [id="{upid}-{api}-config"]
  19. ==== Job configuration
  20. The `Job` object contains all the details about the {anomaly-job}
  21. configuration.
  22. A `Job` requires the following arguments:
  23. ["source","java",subs="attributes,callouts,macros"]
  24. --------------------------------------------------
  25. include-tagged::{doc-tests-file}[{api}-config]
  26. --------------------------------------------------
  27. <1> The job ID
  28. <2> An analysis configuration
  29. <3> A data description
  30. <4> Optionally, a human-readable description
  31. [id="{upid}-{api}-analysis-config"]
  32. ==== Analysis configuration
  33. The analysis configuration of the {anomaly-job} is defined in the `AnalysisConfig`.
  34. `AnalysisConfig` reflects all the configuration
  35. settings that can be defined using the REST API.
  36. Using the REST API, we could define this analysis configuration:
  37. [source,js]
  38. --------------------------------------------------
  39. "analysis_config" : {
  40. "bucket_span" : "10m",
  41. "detectors" : [
  42. {
  43. "detector_description" : "Sum of total",
  44. "function" : "sum",
  45. "field_name" : "total"
  46. }
  47. ]
  48. }
  49. --------------------------------------------------
  50. // NOTCONSOLE
  51. Using the `AnalysisConfig` object and the high level REST client, the list
  52. of detectors must be built first.
  53. An example of building a `Detector` instance is as follows:
  54. ["source","java",subs="attributes,callouts,macros"]
  55. --------------------------------------------------
  56. include-tagged::{doc-tests-file}[{api}-detector]
  57. --------------------------------------------------
  58. <1> The function to use
  59. <2> The field to apply the function to
  60. <3> Optionally, a human-readable description
  61. Then the same configuration would be:
  62. ["source","java",subs="attributes,callouts,macros"]
  63. --------------------------------------------------
  64. include-tagged::{doc-tests-file}[{api}-analysis-config]
  65. --------------------------------------------------
  66. <1> Create a list of detectors
  67. <2> Pass the list of detectors to the analysis config builder constructor
  68. <3> The bucket span
  69. [id="{upid}-{api}-data-description"]
  70. ==== Data description
  71. After defining the analysis config, the next thing to define is the
  72. data description, using a `DataDescription` instance. `DataDescription`
  73. reflects all the configuration settings that can be defined using the
  74. REST API.
  75. Using the REST API, we could define this metrics configuration:
  76. [source,js]
  77. --------------------------------------------------
  78. "data_description" : {
  79. "time_field" : "timestamp"
  80. }
  81. --------------------------------------------------
  82. // NOTCONSOLE
  83. Using the `DataDescription` object and the high level REST client, the same
  84. configuration would be:
  85. ["source","java",subs="attributes,callouts,macros"]
  86. --------------------------------------------------
  87. include-tagged::{doc-tests-file}[{api}-data-description]
  88. --------------------------------------------------
  89. <1> The time field
  90. include::../execution.asciidoc[]
  91. [id="{upid}-{api}-response"]
  92. ==== Response
  93. The returned +{response}+ returns the full representation of
  94. the new {ml} job if it has been successfully created. This will
  95. contain the creation time and other fields initialized using
  96. default values:
  97. ["source","java",subs="attributes,callouts,macros"]
  98. --------------------------------------------------
  99. include-tagged::{doc-tests-file}[{api}-response]
  100. --------------------------------------------------
  101. <1> The creation time is a field that was not passed in the `Job` object in the request