Error analysis using status codes
The statusCode column of our data source contains information about the HTTP traffic in our web site. The value 200 represents a 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 and in the Finder, select demo → ecommerce → data to access the demo.ecommerce.data table.
First, we want to differentiate the positive results (code 200) from the other error codes. We will use the Decode function 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 in the query window toolbar.
Now enter a name for the new column (for example, code200) and select Decode, switch 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 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 vertical scroll to locate it. Select its header and drag it next to the statusCode column to facilitate working.
Now click the gear icon in 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 to generate additional data, such as a numeric field to be used as metric. For example, you can create a pie chart grouping the data, then aggregating it to create a count column.
- Select the Group icon in the toolbar.
- Choose No temporal aggrupation from the drop-down list, then add the code200 column as an argument. Select Group by when you're done.
- Now click the Aggregation icon in the toolbar to create the count of Error and OK values. The Count operation is selected by default, so just click Aggregate function.
- Finally, select the gear icon in the toolbar and click Charts → Diagrams → Pie chart. Drag the count column to the Values field, and the code200 column to the Partitioning field.