Step 1. Error analysis using status codes
The statusCode column of our data source contains information about the HTTP traffic on our website. The value 200 represents correct access to the page. This is usually the most frequent value for this parameter. Other codes, such as 4XX or 5XX, are particularly relevant when looking for errors or unusual situations.
Suppose you want to analyze the status code distribution in our demo data source and identify status codes different than 200.
Go to Data Search → Explore Your Data and in the finder, select demo → ecommerce → data to access the
First, we want to differentiate the positive results (code 200) from the other error codes. We will use the Decode, switch (decode) operation to create a new column that shows OK for 200 codes and Error for codes different than 200. To do it, select the Create column icon on the toolbar.
Now enter a name for the new column (for example, code200) and select Decode, switch (decode) as the operation. Click New argument to add the fields and values that will define the conditions of the operation.
The following table describes the 4 arguments we need to add:
Argument Value Description When Select the statusCode column from the drop-down list. This is the column from which we want to take the status code values. is Click the pencil icon and enter 200. This is the first condition of the operation. In this case, we want to transform status codes 200. transform to Click the pencil icon and enter OK. We want to transform status codes 200 to OK in the new column. otherwise Click the pencil icon and enter Error. In the case of codes other than 200, the new column will show Error.
Select Create column. The new column will be added to the right of the table. Use the horizontal scroll to locate it. Select its header and drag it next to the statusCode column to facilitate working.
Now click the gear icon on the toolbar and select Charts → Plots → Histogram. Drag the new code200 column to the window to visualize the amount of OK and Error values.
You don't need to group or aggregate the data to generate a histogram. However, other charts require generating additional data, such as a numeric field to be used as a metric. For example, you can create a pie chart grouping the data, then aggregating it to create a count column.
- Select the Group icon on the toolbar.
- Choose No time-based grouping from the drop-down list, then add the code200 column as an argument. Select Group when you're done.
- Now click the Aggregate icon on the toolbar to create the count of Error and OK values. The Count operation is selected by default, so just click Aggregate.
- Finally, select the gear icon on the toolbar and click Charts → Diagrams → Pie chart. Drag the count column to the Values field, and the code200 column to the Partitioning field.