---
title: New Relic NRDB actions
source: https://docs.newrelic.com/docs/workflow-automation/setup-and-configure/actions-catalog/newrelic/query/newrelic-nrdb
---

This page provides a reference for New Relic NRDB actions available in the workflow automation actions catalog. These actions enable you to query the New Relic database.

## Prerequisites

Before using New Relic NRDB actions in workflow automation, ensure you have:

-   A New Relic account with appropriate permissions.
-   A New Relic license key (if sending data to a different account).
-   The necessary permissions for the specific New Relic services you plan to use.

See [License Key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys#license-key) for information on how to create and manage your New Relic Account License Key.

## Query NRDB

The action identifier is `newrelic.nrdb.query`.

Executes a cross-account NRQL query through the NerdGraph API.

### Inputs

The following table describes all available input fields for this action.

| Input          | Type        | Description                                                                                                                                                       | Example                                                                                                                                                                                                                                                                                               |
| -------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **query**      | String      | **Required.** The NRQL query statement.                                                                                                                           |                                                                                                                                                                                                                                                                                                       |
| **accountIds** | List of int | **Optional.** New Relic Account IDs specifying the target accounts for query execution. If not provided, the query runs against the workflow's execution account. |                                                                                                                                                                                                                                                                                                       |
| **format**     | Enum        | **Optional.** The output format for results. Accepts `JSON`, `CSV`, `PSV`, or `TSV`. Defaults to `JSON`.                                                          |                                                                                                                                                                                                                                                                                                       |
| **selectors**  | List        | **Optional.** The selectors to get only the specified parameters as output.                                                                                       | ```yaml steps:   - name: queryForLog     type: action     action: newrelic.nrdb.query     version: 1     inputs:       accountIds: [12345]       query: FROM Log SELECT * WHERE message LIKE 'DEMO%'       selectors:         - name: resultsAsString           expression: '.results | tostring' ``` |

### Outputs

The following table describes all output fields returned by this action.

| Output           | Type    | Description                                                                                                                                                                                                                                             |
| ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **results**      | List    | An array of objects containing the results of the query. See [Expressions property](https://docs.newrelic.com/docs/workflow-automation/workflow-automation-apis/definition-schema#expression-properties) for more information.                          |
| **success**      | Boolean | Status of the request.                                                                                                                                                                                                                                  |
| **errorMessage** | String  | Failure reason as message. Example: ```yaml {   "success": true   results=[     { message=[INFO] - Workflow: test has ended, messageId=39af98 },     { message=[INFO] - Workflow: test - Step query has started, messageId=649c612 },     ...   ] } ``` |
