/enrichment
A Graze API endpoint that allows you to add and delete records from the enrichment data store. To use the Enrichment API, you must install Moogsoft Add-ons v2.6 or later and set up the Enrichment API Integration.
After you load data into the enrichment data store, you can add the data to an alert's custom_info
object under the enrichment
key using the Enrichment Workflow Engine getEnrichment function.
For an tutorial on how to use the Enrichment API, see Enrich Alerts Using the Enrichment API.
Back to Graze API EndPoint Reference.
Request arguments
The Enrichment API sends POST requests to the enrichment integration endpoint https://server/graze/v1/integrations/enrichment
using a JSON payload format:
{ "action": <post|delete>, "data": [ <data> ], "age": <age> }
The data
parameter holds an array of objects with keys. The keys are as follows:
attribute
: A string providing a namespace for the data being stored or retrieved. Example: “source”value
: A string the identifies the item being stored or retrieved within the namespace of the attribute. Example: “host1”enrichment
: An object containing the data to be stored against the attribute and value.
The age
parameter is optional and only affects delete actions, as described below.
Action: post
The post
action is used to upload data to the Enrichment API database moog_enrichment
and has the following payload format:
Name | Type | Required | Description |
---|---|---|---|
action | String | Yes | The string "post". |
data | JSON object | Yes | An array of data objects. |
...where a single data object has the following fields:
Name | Type | Required | Description |
---|---|---|---|
attribute | String | Yes | The namespace, ex. "source" |
value | String | Yes | The key within the |
enrichment | JSON object | Yes | The JSON data to store against the attribute and value, ex. { "location":"1265 Battery St., San Francisco, CA", "support_group":"SF NOC" } |
An example payload:
{ "action":"post", "data":[ { "attribute":"source", "value":"SFlinux101", "enrichment": { "location":"1265 Battery St., San Francisco, CA", "support_group":"SF NOC" } }, { "attribute":"source", "value":"DENlinux102", "enrichment": { "location":"1700 Lincoln Street, Denver, CO", "support_group":"DENVER NOC" } } ] }
Action: delete
The delete
action is used to delete records from the Enrichment API database moog_enrichment
and has the following payload format:
Name | Type | Required | Description |
---|---|---|---|
action | String | Yes | The string "delete". |
data | JSON object | Yes | An array of query objects. |
age | Number | No | Optional age in second to limit removal to records above the specified age. |
...where a single query object has the following fields:
Name | Type | Required | Description |
---|---|---|---|
attribute | String | Yes | The namespace, ex. "source". Also accepts the wildcard “*” to match all |
value | String | Yes | The key within the attribute namespace, ex. “SFlinux101”. Also accepts wildcards:
|
An example payload:
{ "action":"delete", "data":[ { "attribute":"source", "value":"SFlinux*" }, { "attribute":"source", "value":"DENlinux102" } ] }
Age scoped deletion
Aged scoped deletion is supported when using the latest version of the Enrichment API database schema. This feature allows you to specify an age
in seconds, so that only matched records that were created or updated more than the specified number of seconds ago will be removed.
Below is an example that will remove all records with attribute “source” and value beginning with "SFlinux” that are more than 3600 seconds old:
{ "action":"delete", "age": 3600, "data":[ { "attribute":"source", "value":"SFlinux*" } ] }
Utility Scripts
This section contains details regarding the two utility scripts bundled in moog_enrichment_utils.zip
, which include new options and features.
If moog_enrichment_utils.zip
is unpacked under $MOOGSOFT_HOME/contrib
, then the following directory structure would be created in $MOOGSOFT_HOME/contrib/moog_enrichment_utils
:
bin/
moog_enrichment_util
moog_enrichment_util.sh
moog_init_enrichmentdb.sh
moog_send_event
data/
...example data
dependencies.txt
node_modules/
package.json
package-lock.json
README.md
Note
The node_modules
directory is pre-populated with the NodeJS dependency. To reinstall the dependencies run:
npm i
Bash script: moog_enrichment_util.sh
A shell script that makes use of the Enrichment API to load or delete data that accepts the following options:
Option | Description |
---|---|
| Supply graze credentials for the Enrichment API. |
| Full URL to graze endpoint, ex: |
| An alternative to the |
| Posts contents of |
| The format of data in the supplied |
| Issue a delete request. Requires either |
| Used with the |
| Used with the |
| Used with the |
| Number of retries on unsuccessful attempts - disabled by default. |
| Backoff interval in seconds - disabled by default. |
| Batch size - number of requests to attempt in one batch - defaults to 5. |
| Enable verbose output. |
| Use the supplied proxy, ex: |
| Used with the |
Uploading data
Sample data is provided in the data
subdirectory for each supported format. To upload the CSV demo data to the server running on the localhost using the default graze credentials:
moog_enrichment_utils]$ ./bin/moog_enrichment_util.sh -H localhost:443 \ -p graze:graze -f data/demo.csv -T csv
Deleting data
To delete all records older then 3600 seconds from the Enrichment API databases:
moog_enrichment_utils]$ ./bin/moog_enrichment_util.sh -H localhost:443 \ -p graze:graze -T DELETE -A -L 3600
To delete all records with an attribute “source” and a value beginning with host1
:
moog_enrichment_utils]$ ./bin/moog_enrichment_util.sh -H localhost:443 \ -p graze:graze -T DELETE -a source -v 'host1*'
NodeJS script: moog_enrichment_util
A NodeJS version of the moog_enrichment_util.sh
script that provides more features and greater reliability. The additional features include:
Generation of sample enrichment data
Post data asynchronously to increase throughput
Option | Description |
---|---|
| Supply graze credentials for the Enrichment API. |
| Full url to graze endpoint, ex. |
| An alternative to the |
| Posts |
| Posts contents of |
| The format of data in the supplied |
| The type of request to perform. Default to “POST” if the option is omitted. |
| Used with the |
| Used with the |
| Used with the |
| Number of retries on unsuccessful attempts - disabled by default. |
| Backoff interval in seconds - disabled by default. |
| Batch size - number of requests to attempt in one batch - defaults to 5. |
| Number of async requests to attempt in parallel. |
| Enable verbose output. |
| Use the supplied proxy, ex. |
| Used with the |
Uploading data
Sample data is provided in the data
subdirectory for each supported format. To upload the CSV demo data to the server running on the localhost using the default graze credentials:
moog_enrichment_utils]$ ./bin/moog_enrichment_util -H localhost:443 \ -p graze:graze -f data/demo.csv -T csv
For initial testing, we can also generate data to upload. The following example shows 10 records being generated and inserted:
moog_enrichment_utils]$ ./bin/moog_enrichment_util -H localhost:443 \ -p graze:graze -n 10 generating 10 records Batch being processed... Batch complete. Batch being processed... Batch complete.
Deleting data
To delete all records older then 3600 seconds from the Enrichment API databases:
moog_enrichment_utils]$ ./bin/moog_enrichment_util -H localhost:443 \ -p graze:graze -T DELETE -A -L 3600
Deleting all records with an attribute “source” and a value beginning with “host1”:
moog_enrichment_utils]$ ./bin/moog_enrichment_util -H localhost:443 \ -p graze:graze -T DELETE -a source -v 'host1*' deleteItem attribute: 'source', value: 'host1*'
Request arguments
Endpoint enrichment
takes the following request payload:
Name | Type | Required | Description |
---|---|---|---|
| String | yes | One of
|
| Array | yes | An array of of enrichment data records represented as JSON objects. |
| String | yes | Name of the alert field or other key for the enrichment data. For example, "source". For the |
| String | yes | The value for the associated attribute. For example if the attribute is "source" for host name data, a value might be "sflinux101". For the delete action, accepts the |
enrichment | JSON object | for | JSON representation of the enrichment data to add to an alert based upon the match attribute and value. For example if you wanted to store store location data: {"location":"1265 Battery St., San Francisco, CA"} |
Example payload:
{"action":"post", "data":[ {"attribute":"source", "value":"SFlinux101", "enrichment": { "location":"1265 Battery St., San Francisco, CA", "support_group":"SF NOC"} }, {"attribute":"source", "value":"DENlinux102", "enrichment": { "location":"1700 Lincoln Street, Denver, CO", "support_group":"DENVER NOC"} }] }
Endpoint enrichment
takes the following request argument:
Response
Endpoint enrichment
returns the following response:
Examples
The following examples demonstrate typical use of endpoint grazeApiEndpointName
:
Request example
Example cURL request to create enrichment data:
curl -k -X POST 'https://localhost/graze/v1/integrations/enrichment' \ --header 'Content-Type: application/json; charset=UTF-8' \ -u graze:graze \ -d '{"action":"post", "data":[ {"attribute":"source", "value":"SFlinux101", "enrichment": { "location":"1265 Battery St., San Francisco, CA", "support_group":"SF NOC"} }, {"attribute":"source", "value":"DENlinux102", "enrichment": { "location":"1700 Lincoln Street, Denver, CO", "support_group":"DENVER NOC"} }]}'