Detector APIs

The following APIs can be used for a number of tasks related to detectors, from creating detectors to updating and searching for detectors.

Create Detector

Creates a new detector.

  1. POST _plugins/_security_analytics/detectors

Parameters

You can specify the following parameters when creating a detector.

ParameterTypeDescription
enabledBooleanEnables the ability to add detectors through the API.
typeStringThe type is specified as “detector”.
nameStringName of the detector.
detector_typeObjectThe log type that defines the detector.
scheduleObjectthe schedule that determines how often the detector runs.
schedule
    period
Objectthe frequency at which the detector runs in repetition.
schedule
    period
        interval
IntegerThe duration of the period expressed as a number.
schedule
    period
        unit
StringThe unit of measure for the interval.
inputsObjectIn process
inputs
    detector_inputs
ObjectIn process
inputs
    detector_inputs
        description
StringIn process
inputs
    detector_inputs
        custom_rules
ObjectIn process
inputs
    detector_inputs
        custom_rules
            id
StringIn process
inputs
    detector_inputs
        indices
StringIn process
inputs
    detector_inputs
        pre_packaged_rules
ObjectIn process
inputs
    detector_inputs
        pre_packaged_rules
            id
StringIn process
triggersObjectIn process
triggers
    ids
StringIn process
triggers
    types
StringIn process
triggers
    tags
StringIn process
triggers
    id
StringIn process
triggers
    sev_levels
StringIn process
triggers
    name
StringIn process
triggers
    severity
IntegerIn process
triggers
    actions
IntegerIn process
triggers
    actions
        id
IntegerIn process
triggers
    actions
        destination_id
IntegerIn process
triggers
    actions
        subject_template
ObjectIn process
triggers
    actions
        subject_template
            source
StringIn process
triggers
    actions
        subject_template
            lang
StringIn process
triggers
    actions
        name
StringIn process
triggers
    actions
        throttle_enabled
BooleanIn process
triggers
    actions
        message_template
StringIn process
triggers
    actions
        message_template
            source
StringIn process
triggers
    actions
        message_template
            lang
StringIn process
triggers
    actions
        throttle
ObjectIn process
triggers
    actions
        throttle
            unit
StringIn process
triggers
    actions
        throttle
            value
IntegerIn process

Sample request

  1. POST _plugins/_security_analytics/detectors
  2. {
  3. "enabled": true,
  4. "schedule": {
  5. "period": {
  6. "interval": 1,
  7. "unit": "MINUTES"
  8. }
  9. },
  10. "detector_type": "WINDOWS",
  11. "type": "detector",
  12. "inputs": [
  13. {
  14. "detector_input": {
  15. "description": "windows detector for security analytics",
  16. "custom_rules": [
  17. {
  18. "id": "bc2RB4QBrbtylUb_1Pbm"
  19. }
  20. ],
  21. "indices": [
  22. "windows"
  23. ],
  24. "pre_packaged_rules": [
  25. {
  26. "id": "06724a9a-52fc-11ed-bdc3-0242ac120002"
  27. }
  28. ]
  29. }
  30. }
  31. ],
  32. "triggers": [
  33. {
  34. "ids": [
  35. "06724a9a-52fc-11ed-bdc3-0242ac120002"
  36. ],
  37. "types": [],
  38. "tags": [
  39. "attack.defense_evasion"
  40. ],
  41. "severity": "1",
  42. "actions": [{
  43. "id": "hVTLkZYzlA",
  44. "destination_id": "6r8ZBoQBKW_6dKriacQb",
  45. "subject_template": {
  46. "source": "Trigger: ",
  47. "lang": "mustache"
  48. },
  49. "name": "hello_world",
  50. "throttle_enabled": false,
  51. "message_template": {
  52. "source": "Detector just entered alert status. Please investigate the issue." +
  53. "- Trigger: " +
  54. "- Severity: ",
  55. "lang": "mustache"
  56. },
  57. "throttle": {
  58. "unit": "MINUTES",
  59. "value": 108
  60. }
  61. }
  62. ],
  63. "id": "8qhrBoQBYK1JzUUDzH-N",
  64. "sev_levels": [],
  65. "name": "test-trigger"
  66. }
  67. ],
  68. "name": "nbReFCjlfn"
  69. }

Sample response

  1. {
  2. "_id": "dc2VB4QBrbtylUb_Hfa3",
  3. "_version": 1,
  4. "detector": {
  5. "name": "nbReFCjlfn",
  6. "detector_type": "windows",
  7. "enabled": true,
  8. "schedule": {
  9. "period": {
  10. "interval": 1,
  11. "unit": "MINUTES"
  12. }
  13. },
  14. "inputs": [
  15. {
  16. "detector_input": {
  17. "description": "windows detector for security analytics",
  18. "indices": [
  19. "windows"
  20. ],
  21. "custom_rules": [
  22. {
  23. "id": "bc2RB4QBrbtylUb_1Pbm"
  24. }
  25. ],
  26. "pre_packaged_rules": [
  27. {
  28. "id": "06724a9a-52fc-11ed-bdc3-0242ac120002"
  29. }
  30. ]
  31. }
  32. }
  33. ],
  34. "triggers": [
  35. {
  36. "id": "8qhrBoQBYK1JzUUDzH-N",
  37. "name": "test-trigger",
  38. "severity": "1",
  39. "types": [],
  40. "ids": [
  41. "06724a9a-52fc-11ed-bdc3-0242ac120002"
  42. ],
  43. "sev_levels": [],
  44. "tags": [
  45. "attack.defense_evasion"
  46. ],
  47. "actions": [
  48. {
  49. "id": "hVTLkZYzlA",
  50. "name": "hello_world",
  51. "destination_id": "6r8ZBoQBKW_6dKriacQb",
  52. "message_template": {
  53. "source": "Trigger: ",
  54. "lang": "mustache"
  55. },
  56. "throttle_enabled": false,
  57. "subject_template": {
  58. "source": "Detector just entered alert status. Please investigate the issue." +
  59. "- Trigger: " +
  60. "- Severity: ",
  61. "lang": "mustache"
  62. },
  63. "throttle": {
  64. "value": 108,
  65. "unit": "MINUTES"
  66. }
  67. }
  68. ]
  69. }
  70. ],
  71. "last_update_time": "2022-10-24T01:22:03.738379671Z",
  72. "enabled_time": "2022-10-24T01:22:03.738376103Z"
  73. }
  74. }

Update Detector

The Update detector API is used for updating a detector.

  1. PUT /_plugins/_security_analytics/detectors/<detector_Id>

Sample request

  1. PUT /_plugins/_security_analytics/detectors/J1RX1IMByX0LvTiGTddR
  2. {
  3. "type": "detector",
  4. "detector_type": "windows",
  5. "name": "windows_detector",
  6. "enabled": true,
  7. "createdBy": "chip",
  8. "schedule": {
  9. "period": {
  10. "interval": 1,
  11. "unit": "MINUTES"
  12. }
  13. },
  14. "inputs": [
  15. {
  16. "input": {
  17. "description": "windows detector for security analytics",
  18. "indices": [
  19. "windows"
  20. ],
  21. "rules": [
  22. {
  23. "id": "46"
  24. }
  25. ]
  26. }
  27. }
  28. ],
  29. "triggers": [
  30. {
  31. "sev_levels": [],
  32. "tags": [],
  33. "actions": [],
  34. "types": [
  35. "windows"
  36. ],
  37. "name": "test-trigger",
  38. "id": "fyAy1IMBK2A1DZyOuW_b"
  39. }
  40. ]
  41. }

Sample response

  1. {
  2. "_id": "J1RX1IMByX0LvTiGTddR",
  3. "_version": 1,
  4. "detector": {
  5. "name": "windows_detector",
  6. "detector_type": "windows",
  7. "enabled": true,
  8. "schedule": {
  9. "period": {
  10. "interval": 1,
  11. "unit": "MINUTES"
  12. }
  13. },
  14. "inputs": [
  15. {
  16. "detector_input": {
  17. "description": "windows detector for security analytics",
  18. "indices": [
  19. "windows"
  20. ],
  21. "rules": [
  22. {
  23. "id": "LFRY1IMByX0LvTiGZtfh"
  24. }
  25. ]
  26. }
  27. }
  28. ],
  29. "triggers": [],
  30. "last_update_time": "2022-10-14T02:36:32.909581688Z",
  31. "enabled_time": "2022-10-14T02:33:34.197Z"
  32. }
  33. }

Delete Detector

This API is used for deleting a detector.

Sample request

  1. DELETE /_plugins/_security_analytics/detectors/J1RX1IMByX0LvTiGTddR

Get Detector

The Get detector API retrieves the detector details.

Sample request

  1. GET /_plugins/_security_analytics/detectors/MFRg1IMByX0LvTiGHtcN

Sample response

  1. {
  2. "_id": "MFRg1IMByX0LvTiGHtcN",
  3. "_version": 1,
  4. "detector": {
  5. "name": "windows_detector",
  6. "detector_type": "windows",
  7. "enabled": true,
  8. "schedule": {
  9. "period": {
  10. "interval": 1,
  11. "unit": "MINUTES"
  12. }
  13. },
  14. "inputs": [
  15. {
  16. "detector_input": {
  17. "description": "windows detector for security analytics",
  18. "indices": [
  19. "windows"
  20. ],
  21. "rules": []
  22. }
  23. }
  24. ],
  25. "last_update_time": "2022-10-14T02:43:11.693Z",
  26. "enabled_time": "2022-10-14T02:43:11.693Z"
  27. }
  28. }

Search Detector

The Search detector API searches for detector matches by detector ID.

Sample request

  1. POST /_plugins/_security_analytics/detectors/_search
  2. Body:
  3. {
  4. "query": {
  5. "match": {
  6. "_id": "MFRg1IMByX0LvTiGHtcN"
  7. }
  8. }
  9. }

Sample response

  1. {
  2. "took": 2,
  3. "timed_out": false,
  4. "_shards": {
  5. "total": 1,
  6. "successful": 1,
  7. "skipped": 0,
  8. "failed": 0
  9. },
  10. "hits": {
  11. "total": {
  12. "value": 1,
  13. "relation": "eq"
  14. },
  15. "max_score": 1.0,
  16. "hits": [
  17. {
  18. "_index": ".opensearch-detectors-config",
  19. "_id": "MFRg1IMByX0LvTiGHtcN",
  20. "_version": 1,
  21. "_seq_no": 6,
  22. "_primary_term": 1,
  23. "_score": 1.0,
  24. "_source": {
  25. "type": "detector",
  26. "name": "windows_detector",
  27. "detector_type": "WINDOWS",
  28. "enabled": true,
  29. "enabled_time": 1665715391693,
  30. "schedule": {
  31. "period": {
  32. "interval": 1,
  33. "unit": "MINUTES"
  34. }
  35. },
  36. "inputs": [
  37. {
  38. "detector_input": {
  39. "description": "windows detector for security analytics",
  40. "indices": [
  41. "windows"
  42. ],
  43. "rules": []
  44. }
  45. }
  46. ],
  47. "triggers": [
  48. {
  49. "id": "fyAy1IMBK2A1DZyOuW_b",
  50. "name": "test-trigger",
  51. "types": [
  52. "windows"
  53. ],
  54. "sev_levels": [],
  55. "tags": [],
  56. "actions": []
  57. }
  58. ],
  59. "last_update_time": 1665715391693,
  60. "monitor_id": [
  61. "LlRf1IMByX0LvTiGzdeX"
  62. ]
  63. }
  64. }
  65. ]
  66. }
  67. }