On This Page

Home / Cribl as Code/ Cribl API/ API Code Examples/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 Code Examples

Code examples use Bearer token authentication. Read the API authentication documentation to learn how to configure authentication. The API Credential (Cribl.Cloud and hybrid) or login credentials (on-prem) that you use to obtain the Bearer token must have the necessary Permissions for the operations in code examples.

Replace the variables in code examples with the corresponding information for your Cribl deployment.

For on-prem deployments, to use https in request URLs, you must configure Transport Layer Security (TLS).

Code examples do not include all available body parameters. For a complete list of body parameters for specific endpoints, refer to the documentation in the API Reference.

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:

On-Prem (Single-Instance)

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 on-prem 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:

Cribl.Cloud and HybridOn-Prem (Distributed Deployment)

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/myGroup/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 /products/${productName}/groups/${groupId}$/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:

Cribl.Cloud and HybridOn-Prem (Distributed Deployment)

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

{"items":[{"description":"My Worker Group","tags":"myTag","type":"stream","configVersion":"abcd1234efgh5678ijkl9101mnop1121qrst3141","lookupDeployments":[],"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:

Cribl.Cloud and HybridOn-Prem (Distributed Deployment)

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:

Cribl.Cloud and HybridOn-Prem (Distributed Deployment)