set-connector-sync-job-stats-api.asciidoc 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. [[set-connector-sync-job-stats-api]]
  2. === Set connector sync job stats API
  3. ++++
  4. <titleabbrev>Set connector sync job stats</titleabbrev>
  5. ++++
  6. preview::[]
  7. .New API reference
  8. [sidebar]
  9. --
  10. For the most up-to-date API details, refer to {api-es}/group/endpoint-connector[Connector APIs].
  11. --
  12. Sets connector sync job stats.
  13. To get started with Connector APIs, check out <<es-connectors-tutorial-api, our tutorial>>.
  14. [[set-connector-sync-job-stats-api-request]]
  15. ==== {api-request-title}
  16. `PUT _connector/_sync_job/<connector_sync_job_id>/_stats`
  17. [[set-connector-sync-job-stats-api-prereqs]]
  18. ==== {api-prereq-title}
  19. * To sync data using self-managed connectors, you need to deploy the <<es-connectors-deploy-connector-service,Elastic connector service>>. on your own infrastructure. This service runs automatically on Elastic Cloud for Elastic managed connectors.
  20. * The `connector_sync_job_id` parameter should reference an existing connector sync job.
  21. [[set-connector-sync-job-stats-api-desc]]
  22. ==== {api-description-title}
  23. Sets the stats for a connector sync job.
  24. Stats include: `deleted_document_count`, `indexed_document_count`, `indexed_document_volume` and `total_document_count`.
  25. `last_seen` can also be updated using this API.
  26. This API is mainly used by the connector service for updating sync job information.
  27. [[set-connector-sync-job-stats-api-path-params]]
  28. ==== {api-path-parms-title}
  29. `<connector_sync_job_id>`::
  30. (Required, string)
  31. [role="child_attributes"]
  32. [[set-connector-sync-job-stats-api-request-body]]
  33. ==== {api-request-body-title}
  34. `deleted_document_count`::
  35. (Required, int) The number of documents the sync job deleted.
  36. `indexed_document_count`::
  37. (Required, int) The number of documents the sync job indexed.
  38. `indexed_document_volume`::
  39. (Required, int) The total size of the data (in MiB) the sync job indexed.
  40. `total_document_count`::
  41. (Optional, int) The total number of documents in the target index after the sync job finished.
  42. `last_seen`::
  43. (Optional, instant) The timestamp to set the connector sync job's `last_seen` property.
  44. `metadata`::
  45. (Optional, object) The connector-specific metadata.
  46. [[set-connector-sync-job-stats-api-response-codes]]
  47. ==== {api-response-codes-title}
  48. `200`::
  49. Indicates that the connector sync job stats were successfully updated.
  50. `404`::
  51. No connector sync job matching `connector_sync_job_id` could be found.
  52. [[set-connector-sync-job-stats-api-example]]
  53. ==== {api-examples-title}
  54. The following example sets all mandatory and optional stats for the connector sync job `my-connector-sync-job`:
  55. [source,console]
  56. ----
  57. PUT _connector/_sync_job/my-connector-sync-job/_stats
  58. {
  59. "deleted_document_count": 10,
  60. "indexed_document_count": 20,
  61. "indexed_document_volume": 1000,
  62. "total_document_count": 2000,
  63. "last_seen": "2023-01-02T10:00:00Z"
  64. }
  65. ----
  66. // TEST[skip:there's no way to clean up after creating a connector sync job, as we don't know the id ahead of time. Therefore, skip this test.]