@@ -67,25 +67,8 @@ code >= 400
67
67
68
68
![ Invalid Syntax] ( ../images/example-queries/equalto-greaterthan-error.png )
69
69
70
- ## Aggregations & Complex Queries
71
-
72
- ** Histogram of log timestamps with status code counts:**
73
- ``` sql
74
- SELECT
75
- histogram(_timestamp) AS ts_histogram,
76
- count (CASE WHEN code = 200 THEN 1 END) AS code_200_count,
77
- count (CASE WHEN code = 401 THEN 1 END) AS code_401_count,
78
- count (CASE WHEN code = 500 THEN 1 END) AS code_500_count
79
- FROM your_stream_name
80
- GROUP BY ts_histogram
81
- ```
82
-
83
- Replace ` your_stream_name ` with the actual stream name in your OpenObserve setup.
84
- - ` histogram(_timestamp) ` bins timestamps into uniform intervals (e.g. hourly). You can configure the granularity in the UI or query if needed.
85
- ![ Histogram of log timestamps] ( ../images/example-queries/histogram.png )
86
-
87
70
88
- ## Filtering Queries
71
+ ## Filtering using WHERE Clause
89
72
90
73
** Filter by service and status code:**
91
74
``` sql
@@ -129,3 +112,19 @@ LIMIT 10
129
112
130
113
131
114
115
+ ## Aggregations & Complex Queries
116
+
117
+ ** Histogram of log timestamps with status code counts:**
118
+ ``` sql
119
+ SELECT
120
+ histogram(_timestamp) AS ts_histogram,
121
+ count (CASE WHEN code = 200 THEN 1 END) AS code_200_count,
122
+ count (CASE WHEN code = 401 THEN 1 END) AS code_401_count,
123
+ count (CASE WHEN code = 500 THEN 1 END) AS code_500_count
124
+ FROM your_stream_name
125
+ GROUP BY ts_histogram
126
+ ```
127
+
128
+ Replace ` your_stream_name ` with the actual stream name in your OpenObserve setup.
129
+ - ` histogram(_timestamp) ` bins timestamps into uniform intervals (e.g. hourly). You can configure the granularity in the UI or query if needed.
130
+ ![ Histogram of log timestamps] ( ../images/example-queries/histogram.png )
0 commit comments