# [[Pathfinder LogQL tutorial]] ![[Project - Pathfinder LogQL tutorial.svg]] ## Steps for contributing a tutorial 1. Get access to push to [interactive tutorials](https://github.com/grafana/interactive-tutorials). 2. Create a new folder with your new project, like `logql-101`. Inside the folder, create a new file called `unstyled.html`. It's easier if you let your LLM of choice do this, but if you don't want to use an LLM, copy and paste the same file from one of the other projects (like `explore-drilldowns-101`) 3. Open up `index.json` and add a block in there for your project like this: ```json { "title": "Interactive Tutorial: LogQL 101 WIP", "url": "https://github.com/grafana/interactive-tutorials/tree/main/logql-101", "description": "Hands-on tutorial: Learn LogQL query language for Grafana Loki.", "type": "docs-page", "match": { "and": [ { "source": "ops.grafana-ops.net", "urlPrefix": "/explore" } ] } }, ``` - The `source` is ops.grafana-ops.net if you want to use one of the already approved datasources. - `urlPrefix` is the page on Grafana where your tutorial will be available. (Navigate to that page and click on the `?` icon.) 4. Modify the HTML to add steps and sections. Terminology: - *Section:* A section is a series of steps that fulfill one task. A section corresponds to a span in the HTLM. - *Multistep*: A multistep is a single step that requires multiple related actions that are dependent on the preceding actions. (For example, clicking on a down arrow and then selecting something from the resulting dropdown list). - *Step:* A step is a single concrete action that can stand on its own. It corresponds to a list item (`<li>`) in Pathfinder. ## Objectives ### Basic LogQL tutorial for Nginx logs 1. Select data source 2. Run a query with just label selectors (`{service_name="nginx_access_log"}`) 3. Briefly go through the results 4. Expand query: another label selector + filter expression `{service_name="nginx_access_log", host="apfelstrudel"} |= "500"` 5. `!=` filter expression (HTTP status = 200) 6. Chaining filter expressions together (|= 500 and != 200) `{service_name="nginx_access_log", host="apfelstrudel"} |= "500" != "200"` 7. JSON parser: `{service_name="nginx_access_log", host="appfelstrudel"} | json | status = "500"` 8. Regular expression 9. Line format to clear up the results 10. Metrics from logs (`count_over_time`, `rate`, `sum by()`)) ### Super awesome murder mystery thing ## Resources - [[Jay Clifford]] - [[2025-09-30 Sync with Jay]] - meeting where Jay showed me how to use Pathfinder - [grafana-pathfinder-app](https://github.com/grafana/grafana-pathfinder-app) is the Pathfinder plugin repo. This contains the code for how Pathfinder itself works, not any of the tutorials - [interactive tutorials](https://github.com/grafana/interactive-tutorials) is where all the tutorials that Pathfinder pulls from are stored. - [grafana-recommender](https://github.com/grafana/grafana-recommender) is the repo for the Recommender component, which you may need to run locally if you're not using datasources already in ops. %% # Excalidraw Data ## Text Elements ## Drawing ```json { "type": "excalidraw", "version": 2, "source": "https://github.com/zsviczian/obsidian-excalidraw-plugin/releases/tag/2.1.4", "elements": [ { "id": "4y8R7iOA", "type": "text", "x": 118.49495565891266, "y": -333.44393157958984, "width": 3.8599853515625, "height": 24, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", "fillStyle": "solid", "strokeWidth": 2, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "groupIds": [], "frameId": null, "roundness": null, "seed": 967149026, "version": 2, "versionNonce": 939059582, "isDeleted": true, "boundElements": null, "updated": 1713723615080, "link": null, "locked": false, "text": "", "rawText": "", "fontSize": 20, "fontFamily": 4, "textAlign": "left", "verticalAlign": "top", "containerId": null, "originalText": "", "lineHeight": 1.2 } ], "appState": { "theme": "dark", "viewBackgroundColor": "#ffffff", "currentItemStrokeColor": "#1e1e1e", "currentItemBackgroundColor": "transparent", "currentItemFillStyle": "solid", "currentItemStrokeWidth": 2, "currentItemStrokeStyle": "solid", "currentItemRoughness": 1, "currentItemOpacity": 100, "currentItemFontFamily": 4, "currentItemFontSize": 20, "currentItemTextAlign": "left", "currentItemStartArrowhead": null, "currentItemEndArrowhead": "arrow", "scrollX": 583.2388916015625, "scrollY": 573.6323852539062, "zoom": { "value": 1 }, "currentItemRoundness": "round", "gridSize": null, "gridColor": { "Bold": "#C9C9C9FF", "Regular": "#EDEDEDFF" }, "currentStrokeOptions": null, "previousGridSize": null, "frameRendering": { "enabled": true, "clip": true, "name": true, "outline": true } }, "files": {} } ``` %%