|
| 1 | +--- |
| 2 | +title: Create an Ingest Pipeline |
| 3 | +linkTitle: 3.3 Create an Ingest Pipeline |
| 4 | +weight: 4 |
| 5 | +--- |
| 6 | + |
| 7 | +In this section you will create an Ingest Pipeline which will convert Kubernetes Audit Logs to metrics which are sent to the Splunk Observability Cloud workshop organization. |
| 8 | + |
| 9 | +{{% notice title="Exercise: Create Ingest Pipeline" style="green" icon="running" %}} |
| 10 | + |
| 11 | +1. Open the **Ingest Processor SCS Tenant** using the connection details provided in the Splunk Show event. |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +{{% notice title="Note" style="primary" icon="lightbulb" %}} |
| 16 | + |
| 17 | +When you open the **Ingest Processor SCS Tenant**, if you are taken to a welcome page, click on **Launch** under **Splunk Cloud Platform** to be taken the the Data Management page where you will configure the Ingest Pipeline. |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +{{% /notice %}} |
| 22 | + |
| 23 | +2. From the Splunk Data Management console select **Pipelines** -> **New pipeline** -> **Ingest Processor pipeline**. |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +3. In the **Get started** step of the Ingest Processor configuration page select **Blank Pipeline** and click **Next**. |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +4. In the **Define your pipeline’s partition** step of the Ingest Processor configuration page select **Partition by sourcetype**. Select the **= equals** Operator and enter `kube:apiserver:audit:PARTICIPANT_NUMBER` (Be sure to replace PARTICIPANT_NUMBER with the participant number you were assigned) for the value. Click **Apply**. |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | +5. Click **Next** |
| 36 | + |
| 37 | +6. In the **Add sample data** step of the Ingest Processor configuration page select **Capture new snapshot**. Enter `k8s_audit` for the name and click **Capture**. |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +7. Make sure your newly created snapshot (`k8s_audit`) is selected and then click **Next**. |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +8. In the **Select a metrics destination** step of the Ingest Processor configuration page select **show_o11y_org**. Click **Next**. |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +9. In the **Select a data destination** step of the Ingest Processor configuration page select **splunk_indexer**. Under **Specify how you want your events to be routed to an index** select **Default**. Click **Done**. |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | +10. In the **Pipeline search field** replace the default search with the following. |
| 54 | + |
| 55 | +{{% notice title="Note" style="primary" icon="lightbulb" %}} |
| 56 | +**Replace `UNIQUE_FIELD` in the metric name with a unique value which will be used to identify your metric in Observability Cloud.** |
| 57 | +{{% /notice %}} |
| 58 | + |
| 59 | +``` |
| 60 | +/*A valid SPL2 statement for a pipeline must start with "$pipeline", and include "from $source" and "into $destination".*/ |
| 61 | +/* Import logs_to_metrics */ |
| 62 | +import logs_to_metrics from /splunk/ingest/commands |
| 63 | +$pipeline = |
| 64 | +| from $source |
| 65 | +| thru [ |
| 66 | +//define the metric name, type, and value for the Kubernetes Events |
| 67 | +| logs_to_metrics name="k8s_audit_UNIQUE_FIELD" metrictype="counter" value=1 time=_time |
| 68 | +| into $metrics_destination |
| 69 | +] |
| 70 | +| eval index = "kube_logs" |
| 71 | +//Send unfiltered logs to S3 |
| 72 | +| into $destination; |
| 73 | +``` |
| 74 | +{{% notice title="New to SPL2?" style="info" icon="lightbulb" %}} |
| 75 | + |
| 76 | +Here is a breakdown of what the SPL2 query is doing: |
| 77 | +* First, you are importing the built in `logs_to_metrics` command which will be used to convert the kubernetes events to metrics. |
| 78 | +* You're using the source data, which you can see on the right is any event from the `kube:apiserver:audit` sourcetype. |
| 79 | +* Now, you use the `thru` command which writes the source dataset to the following command, in this case `logs_to_metrics`. |
| 80 | +* You can see that the metric name (`k8s_audit`), metric type (`counter`), value, and timestamp are all provided for the metric. You’re using a value of 1 for this metric because we want to count the number of times the event occurs. |
| 81 | +* Next, you choose the destination for the metric using the into `$metrics_destintation` command, which is our Splunk Observability Cloud organization |
| 82 | +* Finally, you can send the raw log events to another destination, in this case another index, so they are retained if we ever need to access them. |
| 83 | + |
| 84 | +{{% /notice %}} |
| 85 | + |
| 86 | +11. In the upper-right corner click the **Preview** button  or press CTRL+Enter (CMD+Enter on Mac). From the **Previewing $pipeline** dropdown select **$metrics_destination**. Confirm you are seeing a preview of the metrics that will be sent to Splunk Observability Cloud. |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | +12. In the upper-right corner click the **Save pipeline** button . Enter a name for your pipeline and click **Save**. |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | +13. After clicking save you will be asked if you would like to apply the newly created pipeline. Click **Yes, apply**. |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | +<center> |
| 99 | +<b>The Ingest Pipeline should now be sending metrics to Splunk Observability Cloud. Keep this tab open as it will be used it again in the next section.</b> |
| 100 | + |
| 101 | +In the next step you'll confirm the pipeline is working by viewing the metrics you just created in Splunk Observability Cloud. |
| 102 | +</center> |
| 103 | + |
| 104 | +{{% /notice %}} |
0 commit comments