Create a Widget

In the previous chapter we've seen how to make a basic search like filtering for a specific status code. Now let's make a widget based on this same field.

  1. Enter the following in the Query Editor:

    logscale
    timechart(statuscode)

    This will show a chart, an area graph with a different color for each status code. It will be displayed as a time based graph, but for all HTTP status codes.

  2. Let's change the look a bit. Click the brush formatting icon on the right: that will open a panel for choosing different settings for how the data will be displayed:

    Timechart Widget for Statuscode from HTTP Logs

    Figure 7. Timechart Widget for Statuscode from HTTP Logs


  3. Play with some of the choices. For the screenshot here, we chose to leave it as an area style. We change the Stacking to stack the values instead of overlaying them. We also changed the interpolation type to Step After:

    Stacked Timechart Widget for Statuscode from HTTP Logs

    Figure 8. Stacked Timechart Widget for Statuscode from HTTP Logs


  4. Once you're happy with your chart, let's save this query as it is to a widget:

    1. Click on the Save menu button at the top right.

    2. From the small pull-down menu that appears, select Dashboard Widget.

    3. A box will appear that asks as to which dashboard to save it, select New Dashboard.

    4. Give the new dashboard a name, for example Web Server Dashboard.

    5. You'll also have to enter a name for the widget. Use HTTP Status Codes. You can enter a description of the widget.

    6. Uncheck the box where it says, Open Dashboard After Save.

    7. Click Save.

  5. To be able to easily identify the not-found pages in your dashboard, let's change the search query. This won't affect the widget you just created. For the new query, let's get events with a status code of 404 and put those results in a table, rather than a graph.

    To do this, we'll have to enter a little more complicated query. Enter the following in the search field and click Run:

    logscale
    statuscode = "404"
    | top(url, limit=30)
    | table([url, _count], sortby=_count)

    The first line here will give you all of the entries in the repository with a statuscode of 404. The second line says to group the results based on URL and to return the top thirty URLs. The third line says to put the results in a table with two columns — the URL and the number of occurrences for each URL — and to sort them based on the count of each URL.

  6. When this query is run, you should see an ordered list of all not-found pages, with the ones with the highest count at the top. Let's turn this into a widget for the dashboard. Click the Save As button and select Dashboard Widget. This time you'll see that it offers to save it to the dashboard you already created. Use it; don't create a new dashboard. Enter an appropriate widget title and description. Then press Save — without unchecking the Open Dashboard after save checkbox.

Check out our LogScale tutorial for more guidelines on how to create widgets at the Widgets introductory page.

For the detailed documentation on how to use widgets, see Managing Widgets.

Find the list of all LogScale widget types at Widgets.