Skip to content

Commit 0ca86c5

Browse files
committed
Add Query Logs action and update documentation for New Relic component (retry)
1 parent acc0d11 commit 0ca86c5

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

components/new_relic/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,25 @@
22

33
The New Relic API offers powerful capabilities for monitoring, alerting, and analyzing the performance of your web applications and infrastructure. By using the API within Pipedream, you can automate and orchestrate a vast array of operations that revolve around your application's health and data insights. This can range from triggering workflows based on New Relic alerts, to syncing performance data with other tools, or even automating responses to specific incidents.
44

5+
# Available Actions
6+
7+
- **New Deployment**: Create a new deployment mark in New Relic. Useful for tracking releases and correlating them with application performance or incidents.
8+
- **Query Logs**: Query logs from New Relic using NRQL (New Relic Query Language). This action allows you to fetch and analyze log data directly from New Relic, enabling advanced monitoring and troubleshooting workflows.
9+
510
# Example Use Cases
611

712
- **Automated Incident Response**: When New Relic detects an anomaly or a performance issue, it can trigger a Pipedream workflow that automatically posts a message to a Slack channel, alerting the relevant team. The workflow could also create a ticket in Jira, ensuring that the incident is tracked and managed properly.
813

914
- **Performance Metrics to Data Warehouse**: Set up a Pipedream workflow that periodically fetches performance metrics from New Relic and inserts this data into a Google BigQuery data warehouse. This allows for advanced analysis alongside other business metrics, giving a more comprehensive view of how application performance impacts the overall business.
1015

1116
- **Dynamic Configuration Updates**: If New Relic reports that a service is experiencing high traffic, a Pipedream workflow can interact with other APIs, such as a feature flagging service like LaunchDarkly, to dynamically adjust application features or throttle user access to maintain service stability.
17+
18+
- **Log Analysis and Alerting**: Use the Query Logs action to search for error patterns or specific events in your New Relic logs. For example, you can run an NRQL query like `SELECT * FROM Log WHERE message LIKE '%error%' LIMIT 10` to find recent error logs and trigger downstream actions or notifications.
19+
20+
# Query Logs Action Usage
21+
22+
To use the Query Logs action, provide:
23+
- **Account ID**: Your New Relic account ID.
24+
- **NRQL Query**: The NRQL query to run against your logs (e.g., `SELECT * FROM Log WHERE message LIKE '%timeout%' LIMIT 5`).
25+
26+
The action will return the results of your query, which can be used in subsequent steps of your Pipedream workflow.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { axios } from "@pipedream/platform";
2+
import app from "../../new_relic.app.mjs";
3+
4+
export default {
5+
name: "Query Logs",
6+
description: "Query logs from New Relic using NRQL.",
7+
key: "new_relic-query-logs",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
accountId: {
13+
type: "string",
14+
label: "Account ID",
15+
},
16+
nrql: {
17+
type: "string",
18+
label: "NRQL Query",
19+
description: "The NRQL query to run against logs. Example: `SELECT * FROM Log WHERE message LIKE '%error%' LIMIT 10`",
20+
},
21+
},
22+
async run({ $ }) {
23+
const url = `https://api.newrelic.com/graphql`;
24+
const headers = this.app._getHeaders();
25+
const query = `{
26+
actor {
27+
account(id: ${this.accountId}) {
28+
nrql(query: \"${this.nrql}\") {
29+
results
30+
}
31+
}
32+
}
33+
}`;
34+
const response = await axios(this, {
35+
method: "POST",
36+
url,
37+
headers,
38+
data: { query },
39+
});
40+
$.export("$summary", `Queried logs with NRQL: ${this.nrql}`);
41+
return response.data;
42+
},
43+
};

0 commit comments

Comments
 (0)