# [[Log queries in Loki]]
![[Log queries.svg]]
Log queries in [[Grafana Loki|Loki]] are queries written in [[LogQL]] that return all raw log lines matching the conditions of the query. Log queries always return [[Log stream|log streams]].
Here's an example of a log query in LogQL:
```logql
{job="nginx"} |= "GET"
```
And here's an example of what that query might return:
```
2025-07-17T14:00:01Z {job="nginx", instance="1"} GET /index.html 200 OK
2025-07-17T14:00:15Z {job="nginx", instance="1"} GET /about.html 200 OK
2025-07-17T14:01:02Z {job="nginx", instance="1"} GET /contact.html 200 OK
2025-07-17T14:02:44Z {job="nginx", instance="1"} GET /index.html 200 OK
2025-07-17T14:04:10Z {job="nginx", instance="1"} GET /products.html 200 OK
```
In this case, the results returned are only for one log stream: a single unique combination of [[Key-value pairs]]: the log lines returned are for `job="ngingx"` *and* `instance="1"`. If there were log lines returned that were for `instance="2"`, that would constitute a different log stream.
## Core concepts
- [[Log stream|Log streams]]: label sets and their role
- [[Labels]]: how logs are organized and queried
- Log lines: timestamped messages
## LogQL Syntax overview
## Label selectors
- Best practices: (use of `job`, `namespace`, etc)
## Understanding output
- What a log query returns:
- timestamps
- log lines
- associated labels
- time range behavior
## Performance tips
## Common querying mistakes
%%
# 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": {}
}
```
%%