Skip to content

Commit 7ffec2e

Browse files
authored
Update OTel tutorial. (#169)
* Update OTel tutorial. Signed-off-by: Hannah Troisi <htroisi@pixielabs.ai> * Address aimichelle's comments. Signed-off-by: Hannah Troisi <htroisi@pixielabs.ai> * Update Plugin docs. Signed-off-by: Hannah Troisi <htroisi@pixielabs.ai> * tweak Signed-off-by: Hannah Troisi <htroisi@pixielabs.ai>
1 parent d01e6a6 commit 7ffec2e

8 files changed

Lines changed: 167 additions & 54 deletions

File tree

24.9 KB
Loading
198 KB
Loading
213 KB
Loading
128 KB
Loading

content/en/01-about-pixie/04-roadmap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Pixie’s edge compute engine allows us to apply ML/AI on unsampled data. We wil
2121

2222
### Support the ecosystem
2323

24-
Pixie has a versatile execution engine which can ingest and export data in a variety of formats. We plan to export and ingest data in the OpenTelemetry format which will enable developers to consume Pixie data along with the data produced by other tools (Jaeger, Prometheus). We also plan to leverage our [client APIs](/reference/api) in order to support tighter integrations with other open source projects.
24+
Pixie has a versatile execution engine which can ingest and export data in a variety of formats. Pixie currently supports [exporting data in the OpenTelemetry format](/tutorials/integrations/otel/) which enables developers to consume Pixie data along with data produced by other tools (Jaeger, Prometheus. We plan to add ingest in the future. We also plan to leverage our [client APIs](/reference/api) in order to support tighter integrations with other open source projects.
2525

2626
### Non-goals
2727

content/en/01-about-pixie/05-faq.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,7 @@ Go, C++ and Rust are currently supported. The [Roadmap](/about-pixie/roadmap) co
128128

129129
### How do I export data from the Pixie platform? Import data?
130130

131-
Pixie offers two [client libraries](/reference/api/overview/) (Go, Python) to allow developers to easily integrate Pixie observability data into their existing stack.
132-
133-
Pixie does not currently offer data ingestion.
134-
135-
The [Roadmap](/about-pixie/roadmap) contains plans to support exporting or ingesting data in a variety of additional formats.
131+
Pixie offers two [client libraries](/reference/api/overview/) (Go, Python) to allow developers to easily integrate Pixie observability data into their existing stack. You can also use Pixie's [Plugin System](/reference/plugins/plugin-system/) to [export data in the OpenTelemetry format](/tutorials/integrations/otel/). Pixie does not currently offer data ingestion. The [Roadmap](/about-pixie/roadmap) contains plans to support exporting or ingesting data in a variety of additional formats.
136132

137133
### How do I share a Pixie dashboard with others?
138134

content/en/04-tutorials/03-integrations/03-otel.md

Lines changed: 148 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,41 @@
11
---
2-
title: "Export Data to OpenTelemetry"
3-
metaTitle: "Tutorials | Integrations and Alerts | Pixie <> OpenTelemetry"
4-
metaDescription: "Export Data to OpenTelemetry"
2+
title: "Export OpenTelemetry Data"
3+
metaTitle: "Tutorials | Integrations and Alerts | Export OpenTelemetry Data"
4+
metaDescription: "Export OpenTelemetry Data"
55
order: 3
66
redirect_from:
77
- /tutorials/otel/
88
---
99

10+
This tutorial will demonstrate how to export Pixie data in the OpenTelemetry (OTel) format.
1011

11-
Pixie comes packaged with an OpenTelemetry exporter. You can write PxL scripts that define the transformation of Pixie DataFrames into OpenTelemetry data. This article walks through a script that exports HTTP data collected by Pixie into an OpenTelemetry endpoint. More detailed PxL documentation for the OpenTelemetry integration is available [here](/reference/pxl/otel-export).
12+
To do this, we will take the following steps:
1213

14+
1. Deploy an OTel collector to our cluster.
15+
2. Write a PxL script that uses the [OTel methods](/reference/pxl/otel-export/) to transformation Pixie DataFrames into OTel data.
16+
3. Setup the Pixie [Plugin System](/reference/plugins/plugin-system/) to run the PxL script at regularly scheduled intervals.
1317

14-
## Example OpenTelemetry Export PxL Script
18+
Note that [Pixie's API](/using-pixie/api-quick-start/) can also be used to run the PxL scripts developed in Step 2, however this tutorial will cover the Plugin System only.
1519

16-
The following [PxL script](/tutorials/pxl-scripts/write-pxl-scripts/#overview) calculates the rate of HTTP requests made to each pod in your cluster and exports that data as an OpenTelemetry Gauge metric.
20+
## Deploy the OTel Collector
1721

22+
If you don't already have an OTel collector set up, you can follow the directions to deploy our demo collector [here](https://github.com/pixie-io/pixie-demos/tree/main/otel-collector).
1823

19-
```python
24+
Most OTel collectors are configured to forward metrics to _other tools_ such as Prometheus or Jaeger. For the sake of this tutorial, our demo collector simply outputs the metrics it receives to its logs.
25+
26+
## Write the PxL script
27+
28+
PxL scripts are used to query telemetry data collected by the Pixie Platform. Our PxL script will also export the Pixie data in the OTel format. We'll use the Live UI's `Scratch Pad` to develop our PxL script.
29+
30+
1. Open Pixie's [Live UI](/using-pixie/using-live-ui/).
31+
32+
2. Select the `Scratch Pad` script from the `script` drop-down menu in the top left.
33+
34+
3. Open the script editor using the keyboard shortcut: `ctrl+e` (Windows, Linux) or `cmd+e` (Mac).
35+
36+
4. Replace the contents of the `PxL Script` tab with the following. Hover over the code block below to show the copy button in the top-right.
37+
38+
```python:numbers
2039
import px
2140
# Read in the http_events table
2241
df = px.DataFrame(table='http_events', start_time='-10s')
@@ -36,10 +55,8 @@ df.requests_per_s = df.throughput / 10
3655
px.export(df, px.otel.Data(
3756
# endpoint arg not required if run in a plugin that provides the endpoint
3857
endpoint=px.otel.Endpoint(
39-
url='0.0.0.0:98765',
40-
headers={
41-
'apikey': '12345',
42-
}
58+
url='otel-collector.default.svc.cluster.local:4317',
59+
insecure=True
4360
),
4461
resource={
4562
# service.name is required by OpenTelemetry.
@@ -58,13 +75,31 @@ px.export(df, px.otel.Data(
5875
)
5976
]
6077
))
78+
79+
px.display(df)
6180
```
6281

82+
5. Run the script using the `RUN` button in the top right or by using the keyboard shortcut: `ctrl+enter` (Windows, Linux) or `cmd+enter` (Mac).
83+
84+
6. Hide the script editor using `ctrl+e` (Windows, Linux) or `cmd+e` (Mac).
85+
86+
> Your Live UI should output something similar to the following:
6387
88+
<svg title='OTel PxL script output in the Live UI' src='plugin/otel-script-output.png'/>
6489

65-
## The Data
66-
The first part of this script (lines 1-19) read in the `http_events` data and count the number of requests made to each pod from the last 10s.
90+
> This PxL script calculates the rate of HTTP requests made to each pod in your cluster and exports that data as an OTel Gauge metric.
6791
92+
7. To validate that the data has been received by the OTel collector, check logs for the the `otel-collector-*` pod. If the export was successful, you should see logs similar to:
93+
94+
```bash
95+
2022-04-15T20:48:20.633Z INFO loggingexporter/logging_exporter.go:54 MetricsExporter {"#metrics": 32}
96+
```
97+
98+
> If this is your first PxL script, you may want to check out the [Writing a PxL Script Tutorial](/tutorials/pxl-scripts/write-pxl-scripts/) to learn more. We'll give a high-level overview of this script below.
99+
100+
### The Data
101+
102+
The first part of the PxL script (lines 1-19) read in the `http_events` data and count the number of requests made to each pod from the last 10s.
68103

69104
```python
70105
import px
@@ -86,50 +121,39 @@ df = df.groupby(['pod', 'service', 'req_path']).agg(
86121
df.requests_per_s = df.throughput / 10
87122
```
88123

124+
### Exporting
89125

90-
91-
## Exporting
92-
93-
To export the data, you’ll call `px.export` with the DataFrame as the first argument and the export target `px.otel.Data` as the second argument.
94-
126+
To export the data, you’ll call `px.export` with the DataFrame as the first argument and the export target `px.otel.Data` as the second argument.
95127

96128
```python
97129
px.export(df, px.otel.Data(...))
98130
```
99131

100-
101132
The export target (`px.otel.Data`) describes which columns to use for the corresponding OpenTelemetry fields. You specify a column using the same syntax as in a regular query: `df.column_name` or `df[‘column_name’]`. The columns must reference a column available in the `df` argument or the PxL compiler will throw an error
102133

103-
104-
## Specifying a Collector Endpoint and Authentication
134+
### Specifying a Collector Endpoint and Authentication
105135

106136
The PxL OpenTelemetry exporter needs to talk with a collector. You must specify this information via the `endpoint` parameter:
107137

108-
109138
```python
110139
endpoint=px.otel.Endpoint(
111-
url='0.0.0.0:55690',
112-
headers={
113-
'api-key': '12345',
114-
}
140+
url='otel-collector.default.svc.cluster.local:4317',
141+
insecure=True
115142
),
116143
```
117144

145+
The endpoint url must be an OpenTelemetry gRPC endpoint. If the OpenTelemetry gRPC endpoint is not secured with SSL, you can set `insecure=True`. Don’t specify a protocol prefix. Optionally, you can also specify the headers passed to the endpoint. Some OpenTelemetry collector providers look for authentication tokens or api keys in the connection context. The headers field is where you can add this information.
118146

119-
The endpoint url must be an OpenTelemetry grpc endpoint and must be secured with SSL. Don’t specify a protocol prefix. Optionally, you can also specify the headers passed to the endpoint. Some OpenTelemetry collector providers look for authentication tokens or api keys in the connection context. The headers field is where you can add this information.
147+
Note that if you’re writing a [plugin script](/reference/plugins/plugin-system), this information will be passed in by the plugin context and should not be specified. We'll remove this endpoint parameter when we set up the Plugin in Step 3.
120148

121-
Note that if you’re writing a [plugin script](/reference/plugins/plugin-system), this information should be passed in from the plugin context.
122-
123-
124-
## Transforming Data
149+
### Transforming Data
125150

126151
The core idea of the PxL OpenTelemetry export is that you’re converting columnar data from a Pixie DataFrame into the fields of whatever OpenTelemetry data that you wish to capture. You can reference a column by using the attribute syntax `df.column_name`. Under the hood, Pixie will convert the values for each row into a new OpenTelemetry message. The columns must match up with the DataFrame that you are exporting (the first argument to `px.export`), otherwise you will receive a compiler error.
127152

128-
129-
## Specifying a Resource
153+
### Specifying a Resource
130154

131155
The `resource` parameter defines the entity producing the [telemetry data](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md). Users define the `resource` argument as a dictionary mapping attribute keys to the STRING columns that populate the attribute values. The PxL configuration expects `service.name` to be set, all other attributes are optional.
132-
156+
133157
When creating new attribute keys, keep in mind OpenTelemetry has a [recommended pattern](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#document-conventions) that you should follow to maintain broad compatibility with OpenTelemetry collectors.
134158

135159
```python
@@ -141,13 +165,10 @@ resource={
141165
},
142166
```
143167

144-
145-
146-
## Specifying Data
168+
### Specifying Data
147169

148170
The data parameter allows you to specify a list of metrics or traces that are generated from the DataFrame. In the example script, we specify a single Gauge metric for the `df.request_per_s` column. We also supply an attribute for the metric, `req_path`. Each Metric and Trace type supports a custom attribute field. Metric/Trace attributes work similarly to Resource attributes, but they are scoped only to the specific method
149171

150-
151172
```python
152173
data=[
153174
px.otel.metric.Gauge(
@@ -161,6 +182,94 @@ data=[
161182
]
162183
```
163184

164-
165185
We currently support a limited set of OpenTelemetry signal types: `metric.Gauge`, `metric.Summary` and `trace.Span`. We also support a subset of the available fields for each instrument. You can see the full set of features [in our api documentation.](/reference/pxl/otel-export) If you want support for other fields, please [open an issue](https://github.com/pixie-io/pixie).
166186

187+
## Setup the Plugin
188+
189+
Now that we have a PxL script that exports OTel data, let's set up the [Plugin System](/reference/plugins/plugin-system/) to run this script at regularly scheduled intervals.
190+
191+
1. Navigate to the `Plugin` tab on the `Admin` page (`/admin/plugins`).
192+
193+
2. Click the toggle to enable the OpenTelemetry plugin.
194+
195+
3. Expand the plugin row (with the arrow next to the toggle) and enter the export path.
196+
197+
> If you are using the demo collector from [Step 1](/tutorials/integrations/otel/#deploy-the-otel-collector), then you'll use the same export path pictured below: `otel-collector.default.svc.cluster.local:4317`
198+
199+
4. Click the toggle to disable "Secure connections with TLS" and press the `SAVE` button. The demo OTel collector does not support TLS.
200+
201+
<svg title='Plugins are enabled in the Admin UI.' src='plugin/plugins_page.png'/>
202+
203+
5. Click the database icon in the left nav bar to open the data export configuration page.
204+
205+
<svg title='Select the data export icon.' src='plugin/data-export-icon.png'/>
206+
207+
6. The OpenTelemetry plugin comes with several pre-configured OTel export PxL scripts (more coming soon!). Click the toggle to disable these scripts for now. For the sake of this tutorial, we want to ensure that the data that the collector receives is actually from our custom script.
208+
209+
<svg title='Disable the pre-configured OpenTelemetry scripts.' src='plugin/data-export.png'/>
210+
211+
7. Select the `+ CREATE SCRIPT` button.
212+
213+
8. Enter `HTTP Throughput` in the `Script Name` field.
214+
215+
9. Replace the contents of the `PxL` field with the following:
216+
217+
```python
218+
import px
219+
# Read in the http_events table
220+
df = px.DataFrame(table='http_events', start_time=px.plugin.start_time)
221+
222+
# Attach the pod and service metadata
223+
df.pod = df.ctx['pod']
224+
df.service = df.ctx['service']
225+
# Count the number of requests per pod and service
226+
df = df.groupby(['pod', 'service', 'req_path']).agg(
227+
throughput=('latency', px.count),
228+
time_=('time_', px.max),
229+
)
230+
231+
# Change the denominator if you change start_time above.
232+
df.requests_per_s = df.throughput / 10
233+
234+
px.export(df, px.otel.Data(
235+
resource={
236+
# service.name is required by OpenTelemetry.
237+
'service.name' : df.service,
238+
'service.instance.id': df.pod,
239+
'k8s.pod.name': df.pod,
240+
},
241+
data=[
242+
px.otel.metric.Gauge(
243+
name='http.throughput',
244+
description='The number of messages sent per second',
245+
value=df.requests_per_s,
246+
attributes={
247+
'req_path': df.req_path,
248+
}
249+
)
250+
]
251+
))
252+
```
253+
254+
> This is the script we developed in [Step 2](/tutorials/integrations/otel/#write-the-pxl-script) with a few modifications:
255+
256+
> - We changed the DataFrame's `start_time` argument to use `px.plugin.start_time`. This value can be configured using the `Summary Window` field on this page.
257+
258+
> - We removed the `Endpoint` parameter. We configured the plugin with this value in Step 3.
259+
260+
> - We removed the `px.display()` call on the last line. This was used to display the data in the Live UI when developing our script in the Scratch Pad.
261+
262+
10. Select the `OpenTelemetry` option from the `Plugin` field drop-down menu.
263+
264+
11. Click the `SAVE` button.
265+
266+
12. To validate that the data is being received by the OTel collector, check logs for the the `otel-collector-*` pod. If the plugin configuration was successful, you should see logs every 10 seconds:
267+
268+
```bash
269+
2022-04-15T21:17:27.530Z INFO loggingexporter/logging_exporter.go:54 MetricsExporter {"#metrics": 32}
270+
2022-04-15T21:17:37.570Z INFO loggingexporter/logging_exporter.go:54 MetricsExporter {"#metrics": 30}
271+
2022-04-15T21:17:47.609Z INFO loggingexporter/logging_exporter.go:54 MetricsExporter {"#metrics": 29}
272+
2022-04-15T21:17:57.449Z INFO loggingexporter/logging_exporter.go:54 MetricsExporter {"#metrics": 29}
273+
```
274+
275+
Congrats! You're now exporting Pixie data to an OTel collector.

content/en/05-reference/03-plugins/01-plugin-system.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
title: "Pixie Plugin System"
33
metaTitle: "Reference | Plugins | Pixie Plugin System "
44
metaDescription: "Pixie's Plugin System"
5-
order: 1
5+
order: 1
66
---
77

8-
Pixie's primary focus is to build a real-time debugging platform, not a full-fledged observability solution. Pixie provides a plugin system to integrate with external tools to enable capabilities like longterm data retention and alerting.
8+
Pixie's primary focus is to build a real-time debugging platform, not a full-fledged observability solution. Use the plugin system to integrate with external tools to enable capabilities like longterm data retention and alerting.
99

10-
- [*Longterm Data Retention*](#longterm-data-retention): Pixie only retains up to 24 hours of data. Leverage an external datastore for longterm data retention by sending Pixie data in the [OpenTelemetry](https://opentelemetry.io/) format. Future support will be added for querying longterm data from within the Pixie UI, allowing you to use PxL and Pixie's versatile live views.
11-
- *Alerts* (Coming Soon!): Power alerts using Pixie's rich dataset, all configurable from within Pixie's UI.
10+
- [Longterm Data Retention](#longterm-data-retention): Pixie retains up to 24 hours of data. Leverage an external datastore for longterm data retention by sending Pixie data in the [OpenTelemetry](https://opentelemetry.io/) format. Future support will be added for querying longterm data from within the Pixie UI.
11+
12+
- [Alerts](#alerts) (coming soon): Power alerts using Pixie's rich dataset, all configurable from within the Pixie UI.
1213

1314
## Enabling a Plugin
1415

15-
Plugins can be configured from within the Admin UI.
16+
Plugins can be configured from within the Admin UI.
1617

1718
<svg title='Plugins are accessible through the Admin UI.' src='plugin/plugins_page.png'/>
1819

@@ -22,15 +23,17 @@ Plugins can be configured from within the Admin UI.
2223

2324
## Longterm Data Retention
2425

25-
Enable a plugin which offers longterm data retention capabilities to send Pixie data to an external datastore. This plugin allows you to configure PxL scripts to export data at regularly scheduled intervals. This only currently supports exporting data through the [OpenTelemetry](https://opentelemetry.io/) format.
26+
<Alert variant="outlined" severity="info">Check out the <a href="/tutorials/integrations/otel/">tutorial</a> to how to export data in the OTel format.</Alert>
27+
28+
Enable a plugin which offers longterm data retention capabilities to send Pixie data to an external datastore. This plugin allows you to configure PxL scripts to export data at regularly scheduled intervals. This only currently supports exporting data through the [OpenTelemetry](https://opentelemetry.io/) format.
2629

2730
By default, the plugin provider has configured a set of preset scripts. These will automatically start running and exporting data from all clusters in the org as soon as the plugin is enabled. Users can also choose to export custom data by creating a custom export script.
2831

2932
### Configuring Preset Export Scripts
3033

3134
<svg title='You can view preset scripts for a plugin in the Data Export page.' src='plugin/preset_scripts.png'/>
3235

33-
1. [Enable a plugin provider](#enabling-a-plugin) which supports longterm data retention.
36+
1. [Enable a plugin provider](#enabling-a-plugin) which supports longterm data retention.
3437
2. Open the Live UI and navigate to the Data Export page in the sidebar (`/configure-data-export`).
3538
3. All preset scripts are listed under `<Plugin Provider> Scripts`.
3639
4. Click the toggle to enable/disable the export from the preset script.
@@ -41,7 +44,7 @@ By default, the plugin provider has configured a set of preset scripts. These wi
4144

4245
<svg title='Create a custom script in the Data Export page by clicking `Create Scripts`.' src='plugin/custom_scripts.png'/>
4346

44-
1. [Enable a plugin provider](#enabling-a-plugin) which supports longterm data retention.
47+
1. [Enable a plugin provider](#enabling-a-plugin) which supports longterm data retention.
4548
2. Open the Live UI and navigate to the Data Export page in the sidebar (`/configure-data-export`).
4649
3. Under `Custom Scripts`, click the `Create Scripts` button on the right-hand side.
4750
4. Enter a script name and description.
@@ -51,7 +54,12 @@ By default, the plugin provider has configured a set of preset scripts. These wi
5154
8. Select the plugin provider to export this data to.
5255
9. Click "Create" to save your settings. Data export should start immediately.
5356

57+
## Alerts
58+
59+
Coming soon!
60+
5461
## Contributing a Plugin
5562

56-
Interested in contributing a plugin to our Plugin system? Check out our [Pixie Plugin Repository](https://github.com/pixie-io/pixie-plugin) and follow the provided instructions.
63+
Interested in contributing a Pixie plugin?
5764

65+
Check out our [Plugin Repository](https://github.com/pixie-io/pixie-plugin) for more details.

0 commit comments

Comments
 (0)