The LogDNA API provides a programmatic way to manage some of the more common tasks of managing Views, Alerts, and other configurations in your account.

Overview

The LogDNA API's Configuration endpoints are used to create, update, and delete the following items:

Authentication

The LogDNA API uses a service key in the Header to provide authentication. HTTP Headers are the part of the API request and response that contain the meta-data associated with the API request and response. You can pass the service key in the header parameter (-H) of your requests, as shown in the Example below. Alternatively, you can pass service key in the username element (-u) of the request and leave the password value as blank/empty.

To generate a service key, go to the LogDNA dashboard and navigate to Settings > Organization > API Keys. The service key generated is specific to the Organization, so by using a specific service key, this ensures that you are working in the intended Organization.

🚧

Back Up Important Account Configurations

We highly recommend using the Export Configuration feature to back up account settings in case of runaway automation or mistakenly applied configurations.

Important Considerations

  • When using the POST method, the name parameter is always required, in order to define the name of the new View or Preset alert.
  • When using PUT you must specify the name and item's exact id parameter (viewid, presetid, etc.).
  • Be aware that if you use PUT on an existing configuration, the PUT action will replace the existing configuration's contents with your request body. This includes Views, view-specific alerts and/or any filters, and preset alerts. Properties not explicitly specified in your request will be removed.
  • Note that refreshing a View in the UI will persist old filter selections that were made in the web application UI, even if the View was subsequently updated by an API. To refresh and see the current configuration, click the name of the View on the left-hand navigation pane, and the configuration will reset with the latest filter/search properties.
  • PagerDuty alerts: If you want to create either a view-specific or a preset alert that uses PagerDuty to notify you, you will need to provide LogDNA with the PagerDuty API key. To ensure that the LogDNA Dashboard properly displays the PagerDuty alert notification channel, we recommend that you first link the PagerDuty service to LogDNA via the Dashboard UI, before using the Configuration API to create a PagerDuty Alert. However, not doing so doesn't in anyway prevent the use of the Configuration API to create Alerts that use PagerDuty.

Views and Alerts

The Configuration endpoints can programmatically create, modify, and delete Views and view-specific alerts, instead of using the LogDNA user interface (UI). You can use the POST method to create a new View and its query, and attach view-specific Alerts to the new View. Use the PUT method to update or modify existing Views and any attached alerts, and the DELETE method to remove Views and view-specific alerts from the account.

What you need to know

Here are the basics that you need to know when using the Configuration API for Views and Alerts.

Methods

Base URL

Endpoints

Response body

GET
POST
PUT
DELETE

https://api.logdna.com

/v1/config/view

/v1/config/view/{viewid}

JSON

Required parameters and header content

Refer to our API Reference documentation for each of the endpoints to learn what are required elements.

Example cURL request for creating a View

You can create your first View with the Config endpoint using your terminal (or API tool of your choice!) and the following curl command:

curl https://api.logdna.com/v1/config/view \
  -H 'servicekey: YOUR_SERVICE_KEY' \
  -H 'content-type: application/json' \
  -d '{
    "name": "name_of_view",
    "query": "level:debug My first automated search query"
  }'

Preset Alerts

The Configuration endpoints can programmatically create, modify, and delete Preset Alerts, instead of using the LogDNA user interface (UI). You can use the POST method to create a new Preset Alert, the PUT method to update or modify existing Preset Alerts, and the DELETE method to remove Preset Alerts from the account.

What you need to know

Here are the basics that you need to know when using the Configuration endpoint for Preset Alerts.

Methods

Base URL

Endpoints

Response body

GET
POST
PUT
DELETE

https://api.logdna.com

/v1/config/presetalert
/v1/config/presetalert/{presetid}

JSON

Required parameters and header content

Refer to our API Reference documentation for each of the endpoints to learn what are required elements.