Update configurations

You can update a configuration or change its type. Updating a configuration does not automatically deploy the changes to NXLog Agent instances. See Sync agent configuration for instructions on syncing an agent’s configuration.

Prerequisites

About updating configurations

A PATCH request to the templates endpoint updates an existing configuration. The command requires the configuration UUID. The following configuration properties can be updated: name, parts, content, tags, and comment. If parts or content are updated, the command creates a new version of the configuration.

$ curl --verbose --request PATCH \
       --url "https://agents.example.com/api/{ORG_ID}/api/v1/templates/{CONFIG_ID}" \
       --header "Authorization: Bearer {TOKEN}" \
       --header "Content-Type: application/json" \
       --header "Accept: */*" \
       --data '{OBJECT}'

If a matching configuration exists and it is updated successfully, the command returns 204 No content.

Rename a configuration

This example renames a configuration by its ID.

PATCH /templates/ea217bc8-3823-11f1-8000-c6dc36d72137

Entity type

templates

Entity UUID

ea217bc8-3823-11f1-8000-c6dc36d72137

Request body

{
  "name": "New configuration name"
}

Try it

Execute the following curl command or Python script to rename a configuration.

curl
$ curl --verbose --request PATCH \
       --url "https://agents.example.com/api/{ORG_ID}/api/v1/templates/{CONFIG_ID}" \(1)
       --header "Authorization: Bearer {TOKEN}" \(2)
       --header "Content-Type: application/json" \
       --header "Accept: */*" \
       --data '{"name": "New configuration name"}'
1 Replace example.com with the NXLog Platform domain you specified when installing NXLog Platform, {ORG_ID} with your organization ID, and {CONFIG_ID} with your configuration UUID.
2 Replace {TOKEN} with your API token. See Generating a token for instructions.
Python
'''
Requires Python 3.x
'''

import requests
import json

# Set these variables for your environment
api_token = '<API_TOKEN>' (1)
base_url = 'https://agents.<DOMAIN>/api' (2)
org = '<ORG_ID>' (3)
config_id = '<CONFIG_ID>' (4)

endpoint = 'api/v1/templates'
url = '{}/{}/{}/{}'.format(base_url, org, endpoint, config_id)
headers = {
    'Authorization': 'Bearer {}'.format(api_token),
    'Content-Type': 'application/json',
    'Accept': '*/*'
}

payload = {'name': 'New configuration name'}
r = requests.patch(url, headers=headers, data=json.dumps(payload))

if r.status_code == 204:
    print('Status: 204')
else:
    print('Error: {} {}'.format(r.status_code, r.text))
1 Replace <API_TOKEN> with your API token. See Generating a token for instructions.
2 Replace <DOMAIN> with the NXLog Platform domain you specified when installing NXLog Platform.
3 Replace <ORG_ID> with your organization ID.
4 Replace <CONFIG_ID> with your configuration UUID.
Example response
Status: 204

Change the configuration type

You can update a configuration to either include other configurations as parts or use a static configuration by specifying the corresponding field. The content and parts fields are mutually exclusive. Therefore, specifying one field in an update request overwrites the other field.

Specifying both the content and parts properties returns 400 Bad Request - Trying to set parts and contents at the same time.

This example changes a configuration consisting of other configurations to static configuration.

PATCH /templates/ea217bc8-3823-11f1-8000-c6dc36d72137

Entity type

templates

Entity UUID

ea217bc8-3823-11f1-8000-c6dc36d72137

Request body

{
  "content": "<Input windows_events>\nModule im_msvistalog\n</Input>\n"
}

Try it

Execute the following curl command or Python script to change a configuration consisting of other configurations to static configuration.

curl
$ curl --verbose --request PATCH \
       --url "https://agents.example.com/api/{ORG_ID}/api/v1/templates/{CONFIG_ID}" \(1)
       --header "Authorization: Bearer {TOKEN}" \(2)
       --header "Content-Type: application/json" \
       --header "Accept: */*" \
       --data '{"content": "<Input windows_events>\nModule im_msvistalog\n</Input>\n"}'
1 Replace example.com with the NXLog Platform domain you specified when installing NXLog Platform, {ORG_ID} with your organization ID, and {CONFIG_ID} with your configuration UUID.
2 Replace {TOKEN} with your API token. See Generating a token for instructions.
Python
'''
Requires Python 3.x
'''

import requests
import json

# Set these variables for your environment
api_token = '<API_TOKEN>' (1)
base_url = 'https://agents.<DOMAIN>/api' (2)
org = '<ORG_ID>' (3)
config_id = '<CONFIG_ID>' (4)

endpoint = 'api/v1/templates'
url = '{}/{}/{}/{}'.format(base_url, org, endpoint, config_id)
headers = {
    'Authorization': 'Bearer {}'.format(api_token),
    'Content-Type': 'application/json',
    'Accept': '*/*'
}

payload = {'content': '<Input windows_events>\nModule im_msvistalog\n</Input>\n'}
r = requests.patch(url, headers=headers, data=json.dumps(payload))

if r.status_code == 204:
    print('Status: 204')
else:
    print('Error: {} {}'.format(r.status_code, r.text))
1 Replace <API_TOKEN> with your API token. See Generating a token for instructions.
2 Replace <DOMAIN> with the NXLog Platform domain you specified when installing NXLog Platform.
3 Replace <ORG_ID> with your organization ID.
4 Replace <CONFIG_ID> with your configuration UUID.
Example response
Status: 204