You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
metaDescription: 'Learn how to add NRQL queries to your New Relic notebooks, customize query blocks, and visualize your data within notebook documents.'
8
+
metaDescription: 'Learn about notebook blocks, active blocks, action toolbars, and how to add and manage query blocks in your New Relic notebooks.'
12
9
freshnessValidatedDate: never
13
10
---
14
11
15
12
Query blocks are the core component of notebooks, allowing you to write NRQL queries and visualize the results directly within your document. You can add multiple query blocks to a single notebook to build a comprehensive data story.
16
13
17
-
## Add a query block
14
+
## Active block
18
15
19
-
To add a query block to your notebook:
16
+
The active block is the currently focused, interactive unit within your notebook. It serves as your immediate workspace for writing code, running queries, or adding documentation.
20
17
21
-
1. Open your notebook in the query console.
22
-
2. Click the **+ Query** button or press **Ctrl+Enter** (or **Cmd+Enter** on Mac) to add a new query block.
23
-
3. Write your NRQL query in the query editor.
24
-
4. Press **Run** or **Enter** to execute the query and display results.
18
+
The active block is immediately visible, making it easy to spot within your notebook. It is identified by two key visual cues:
19
+
***Clear Borders**: The active block is highlighted with a distinct, clear border color.
20
+
***Visible Toolbar**: It is the only cell that displays the actions.
25
21
26
-
<Calloutvariant="tip">
27
-
All NRQL queries supported in the standard query builder work in notebook query blocks. You can query any data type including metrics, events, logs, and traces.
28
-
</Callout>
29
-
30
-
## Write NRQL queries
31
-
32
-
Notebook query blocks support the full range of NRQL (New Relic Query Language) functionality:
22
+
Queries coming from Data Explorer are added to the active block if the active block is of type query. If the active block is currently markdown, a new query block is added.
33
23
34
-
### Basic queries
24
+
To change an active block you need to select or add another block in the notebook.
35
25
36
-
```sql
37
-
SELECTcount(*) FROM Transaction
38
-
WHERE appName ='MyApp'
39
-
SINCE 1 hour ago
40
-
```
26
+
When a Markdown Block is active, it automatically enters an editing mode featuring a convenient two-column layout to optimize your documentation workflow:
27
+
***Editing Column (Left)**: This is where you directly type and format your Markdown code.
28
+
***Live Preview Column (Right)**: This instantly displays a real-time visual preview of your formatted documentation, ensuring accuracy as you type.
To help you optimize your workspace and maintain a clean view, the notebooks interface features an action toolbar. It consolidates core query actions into a compact, icon-based menu and groups secondary controls into a dedicated Actions Menu.
52
33
53
-
### Time series data
34
+
### Core actions (Top of the Query block)
54
35
55
-
```sql
56
-
SELECTcount(*) FROM Transaction
57
-
WHERE appName ='MyApp'
58
-
TIMESERIES 5 minutes
59
-
SINCE 6 hours ago
60
-
```
36
+
These essential, frequently used actions are directly accessible at the top of the query block via intuitive icons:
37
+
***Run query**: This is now represented by a play icon and executes the current query.
38
+
***Recent queries**: Allows you to quickly access and reuse recently executed queries.
39
+
***Recommended queries**: Provides suggestions for queries.
40
+
***Copy query link**: Generates a shareable link to the current query.
61
41
62
-
##Customize query visualizations
42
+
### Actions Menu (Secondary controls)
63
43
64
-
Each query block supports all the visualization options available in the standard query builder:
44
+
The Actions Menu houses additional, less frequently used, or organizational controls to keep your main toolbar uncluttered.
45
+
***Add another query**: Inserts a new, empty query block into your notebook.
46
+
***Remove query**: Deletes the query from multi-query TIMESERIES.
47
+
***PromQL translator**: A utility for translating queries into PromQL (Prometheus Query Language).
48
+
***Clear**: Removes the query from the query input.
49
+
***Create alert**: Initiates the process for setting up a new alert based on the query results.
50
+
***Move up/down/to the top/to the bottom**: Reorganizes the current query block's position within the notebook.
51
+
***Delete block**: Deletes the active block.
65
52
66
-
### Chart types
53
+
##Add a query block
67
54
68
-
***Line charts**: Perfect for time series data and trends
69
-
***Area charts**: Show volume and composition over time
70
-
***Bar charts**: Compare values across categories
71
-
***Pie charts**: Display proportional data
72
-
***Tables**: Show detailed data in rows and columns
73
-
***Billboards**: Highlight single important metrics
55
+
To add a query block to your notebook:
74
56
75
-
### Chart customization
57
+
1. Open your notebook in the query console.
58
+
2. Click the **+ Query** button or press **Ctrl+Enter** (or **Cmd+Enter** on Mac) to add a new query block.
59
+
3. Write your [NRQL query](https://docs.newrelic.com/docs/nrql/nrql-syntax-clauses-functions/) in the query editor.
60
+
4. Press **Run** or **Enter** to execute the query and display results.
76
61
77
-
1. Click the **Chart type** dropdown above your query results.
78
-
2. Select your preferred visualization.
79
-
3. Use the **Chart settings** to customize:
80
-
* Colors and styling
81
-
* Axis labels and ranges
82
-
* Data formatting
83
-
* Thresholds and alerts
62
+
<Calloutvariant="tip">
63
+
All NRQL queries supported in the standard query builder work in notebook query blocks. You can query any data type including metrics, events, logs, and traces. All [chart types](https://docs.newrelic.com/docs/query-your-data/explore-query-data/use-charts/chart-types/) and customizations available in the standard query builder are supported in notebooks.
64
+
</Callout>
84
65
85
66
## Use variables in queries
86
67
@@ -108,13 +89,22 @@ SINCE {{timeRange}}
108
89
109
90
## Query block management
110
91
111
-
### Duplicate a query block
92
+
<CollapserGroup>
93
+
<Collapser
94
+
id="duplicate-query-block"
95
+
title="Duplicate a query block"
96
+
>
112
97
113
98
1. Hover over the query block.
114
99
2. Click the **three-dot menu** in the top-right corner.
115
100
3. Select **Duplicate**.
116
101
117
-
### Move query blocks
102
+
</Collapser>
103
+
104
+
<Collapser
105
+
id="move-query-blocks"
106
+
title="Move query blocks"
107
+
>
118
108
119
109
Reorder your query blocks to improve your narrative flow:
120
110
@@ -126,64 +116,23 @@ Reorder your query blocks to improve your narrative flow:
126
116
***Move to top**
127
117
***Move to bottom**
128
118
129
-
### Delete a query block
119
+
</Collapser>
120
+
121
+
<Collapser
122
+
id="delete-query-block"
123
+
title="Delete a query block"
124
+
>
130
125
131
126
1. Hover over the query block.
132
127
2. Click the **three-dot menu**.
133
128
3. Select **Delete**.
134
129
4. Confirm the deletion.
135
130
136
-
## Query performance tips
137
-
138
-
To ensure your notebooks load quickly and perform well:
139
-
140
-
### Optimize query time ranges
141
-
142
-
* Use specific time ranges instead of open-ended queries
143
-
* Consider using `SINCE` and `UNTIL` clauses for historical analysis
144
-
* Use `LIMIT` to restrict result sets when appropriate
145
-
146
-
### Use efficient NRQL patterns
147
-
148
-
```sql
149
-
-- Good: Efficient aggregation
150
-
SELECTcount(*) FROM Transaction
151
-
WHERE appName ='MyApp'AND duration >1.0
152
-
SINCE 1 hour ago
153
-
154
-
-- Avoid: Overly broad queries without filters
155
-
SELECT*FROM Transaction
156
-
SINCE 1 week ago
157
-
```
158
-
159
-
### Cache query results
160
-
161
-
Query results in notebooks are cached for a short period. If you're iterating on analysis, you can rely on cached results to speed up notebook loading.
162
-
163
-
## Troubleshooting queries
164
-
165
-
### Common query errors
166
-
167
-
**Syntax errors**: Check your NRQL syntax using the [NRQL reference](/docs/nrql/nrql-syntax-clauses-functions).
168
-
169
-
**Data not found**: Verify:
170
-
* Your time range includes data
171
-
* Attribute names are spelled correctly
172
-
* You have access to the data source
173
-
174
-
**Performance issues**:
175
-
* Add more specific `WHERE` clauses
176
-
* Reduce the time range
177
-
* Use `LIMIT` to restrict results
178
-
179
-
### Get help with NRQL
180
-
181
-
* Browse [NRQL examples](/docs/nrql/nrql-examples) for common patterns
182
-
* Check the [NRQL tutorial](/docs/nrql/nrql-tutorials) for learning resources
183
-
* Use the [query builder](/docs/query-your-data/explore-query-data/query-builder/introduction-query-builder) to build queries visually
131
+
</Collapser>
132
+
</CollapserGroup>
184
133
185
134
## What's next?
186
135
187
-
*Learn about [visualizations in notebooks](/docs/query-your-data/explore-query-data/notebooks/visualizations-in-notebooks)
188
-
*Discover how to [share notebooks](/docs/query-your-data/explore-query-data/notebooks/share-notebooks) with your team
189
-
*Explore [notebook examples](/docs/query-your-data/explore-query-data/notebooks/notebooks-examples) for inspiration
136
+
*Return to [Get started with notebooks](/docs/query-your-data/explore-query-data/notebooks/introduction-notebooks) for an overview
137
+
*Explore [Dashboards](/docs/query-your-data/explore-query-data/dashboards/introduction-dashboards) for building persistent data visualizations
138
+
*Learn more about [Chart types](/docs/query-your-data/explore-query-data/use-charts/chart-types) for visualization options
0 commit comments