Home / API/ Workflows/Commit and Deploy Changes

Commit and Deploy Changes

You can use the Cribl API to automate commit and deploy commands in single-instance and distributed deployments and commit a subset of configuration changes.

About the Example Requests

Replace the variables in the example requests with the corresponding information for your Cribl deployment. In the cURL command options, replace ${token} with a valid API Bearer token. You can also set the $token environment variable to match the value of a Bearer token.

For customer-managed deployments, to use https in the URL for your requests as shown in these examples, you must configure Transport Layer Security (TLS).

Commit and Deploy in Single-Instance Deployments

In single-instance deployments, you can commit and deploy changes with one API call to the /version/commit endpoint. The request body must contain the message parameter, whose value is a descriptive commit message. For example:

curl --request POST \
--url 'https://${hostname}:${port}/api/v1/version/commit' \
--header 'Authorization: Bearer ${token}' \
--header 'Content-Type: application/json' \
--data '{
  "message": "automation@cribl:commit"
}'

The response is a JSON object with details about the commit, similar to the following example:

{"items":[{"branch":"master","commit":"abcd1234efgh5678ijkl9101mnop1121qrst3141","root":false,"summary":{"changes":2,"insertions":63,"deletions":1},"files":{"modified":["local/cribl/auth/12345678910111.dat"],"created":["local/cribl/auth/users.json"]}}],"count":1}

Commit and Deploy in Distributed Deployments

In customer-managed distributed deployments, use two separate API requests to commit and deploy changes to a specific Worker Group. Then, send a third API request to keep your Leader in sync with the Worker Group.

1. Commit Pending Changes to the Worker Group

Commit the pending changes to the desired Worker Group. The request body must include two parameters:

  • message: A descriptive commit message.
  • group: The name of the Worker Group.

For example, to commit all pending changes to the myGroup Worker Group:

curl --request POST \
--url 'https://${hostname}:${port}/api/v1/version/commit' \
--header 'Authorization: Bearer ${token}' \
--header 'Content-Type: application/json' \
--data '{
  "message": "automation@cribl:commit",
  "group": "myGroup"
}'

The response is a JSON object with details about the commit, similar to the following example:

{"items":[{"branch":"master","commit":"abcd1234efgh5678ijkl9101mnop1121qrst3141","root":false,"summary":{"changes":3,"insertions":1003,"deletions":2},"files":{"modified":["groups/myGroup/default/cribl/collectors/myCollector/conf.ui-schema.json","groups/newGroup/default/cribl/functions/eventstats/conf.schema.json"],"created":["groups/myGroup/default/cribl/policies.yml"]}}],"count":1}

You’ll need the commit value from the response, abcd1234efgh5678ijkl9101mnop1121qrst3141, for the deploy request in the next step.

2. Deploy Committed Changes

Send a request to PATCH /master/groups/${groupName}$/deploy to deploy the configuration changes that you committed to the Worker Group. The request body must include the version parameter, whose value is the commit value from the response in the previous step:

curl --request PATCH \
--url 'https://${hostname}:${port}/api/v1/master/groups/myGroup/deploy' \
--header 'Authorization: Bearer ${token}' \
--header 'Content-Type: application/json' \
--data '{
  "version": "abcd1234efgh5678ijkl9101mnop1121qrst3141"
}'

The response is a JSON object similar to the following example:

{"items":[{"description":"My Worker Group","tags":"myTag","configVersion":"abcd1234efgh5678ijkl9101mnop1121qrst3141","id":"myGroup"}],"count":1}

3. Commit Changes to the Leader

To keep your Leader in sync with the Worker Group, commit your changes to the Leader. For example:

curl --request POST \
--url 'https://${hostname}:${port}/api/v1/version/commit' \
--header 'Authorization: Bearer ${token}' \
--header 'Content-Type: application/json' \
--data '{
  "message": "automation@cribl:commit"
}'

Selectively Commit Changes

To commit only a subset of configuration changes, send a request body similar to the following example to POST /version/commit. This example selectively commits a sample data file and the updated YAML listing of all sample files to the default Worker Group:

curl --request POST \
--url 'https://${hostname}:${port}/api/v1/version/commit' \
--header 'Authorization: Bearer ${token}' \
--header 'Content-Type: application/json' \
--data '{
  "message": "automation@cribl:commit",
  "group": "default",
  "files": [
    "groups/default/cribl/saved-queries.json",
    "groups/default/local/cribl/samples.yml"
  ]
}'