Skip to content

Commit 4ab30c6

Browse files
Apply suggestions from code review
Co-authored-by: Craig Norris <[email protected]> Signed-off-by: Alexa Kreizinger <[email protected]>
1 parent d6dc97e commit 4ab30c6

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

stream-processing/getting-started/fluent-bit-sql.md

+19-19
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
Stream processing in Fluent Bit uses SQL to perform record queries.
44

5-
For additional information, see the [stream processing README file](https://github.com/fluent/fluent-bit/tree/master/src/stream_processor).
5+
For more information, see the [stream processing README file](https://github.com/fluent/fluent-bit/tree/master/src/stream_processor).
66

77
## Statements
88

99
Use the following SQL statements in Fluent Bit.
1010

11-
### SELECT
11+
### `SELECT`
1212

1313
```sql
1414
SELECT results_statement
@@ -24,7 +24,7 @@ Groups keys from records that originate from a specified stream, or from records
2424
A `SELECT` statement not associated with stream creation will send the results to the standard output interface, which can be helpful for debugging purposes.
2525
{% endhint %}
2626

27-
You can filter the results of this query by applying a condition through a `WHERE` statement. For information about the `WINDOW` and `GROUP BY` statements, see [Aggregation functions](#aggregation-functions).
27+
You can filter the results of this query by applying a condition by using a `WHERE` statement. For information about the `WINDOW` and `GROUP BY` statements, see [Aggregation functions](#aggregation-functions).
2828

2929
#### Examples
3030

@@ -40,7 +40,7 @@ Selects the `code` key from records with tags whose name begins with `apache`:
4040
SELECT code AS http_status FROM TAG:'apache.*';
4141
```
4242

43-
### CREATE STREAM
43+
### `CREATE STREAM`
4444

4545
```sql
4646
CREATE STREAM stream_name
@@ -64,46 +64,46 @@ Creates a new stream called `hello` for all records whose original tag name begi
6464
CREATE STREAM hello AS SELECT * FROM TAG:'apache.*';
6565
```
6666

67-
## Aggregation Functions
67+
## Aggregation functions
6868

6969
You can use aggregation functions in the `results_statement` on keys, which lets you perform data calculation on groups of records. These groups are determined by the `WINDOW` key. If `WINDOW` is unspecified, aggregation functions are applied to the current buffer of records received, which might have a non-deterministic number of elements. You can also apply aggregation functions to records in a window of a specific time interval.
7070

7171
Fluent Bit uses a tumbling window, which is non-overlapping. For example, a window size of `5` performs aggregation computations on records during a five-second interval, then starts new calculations for the next interval.
7272

7373
Additionally, you can use the `GROUP BY` statement to group results by one or more keys with matching values.
7474

75-
### AVG
75+
### `AVG`
7676

7777
```sql
7878
SELECT AVG(size) FROM STREAM:apache WHERE method = 'POST' ;
7979
```
8080

81-
Calculates the average size of POST requests.
81+
Calculates the average size of `POST` requests.
8282

83-
### COUNT
83+
### `COUNT`
8484

8585
```sql
8686
SELECT host, COUNT(*) FROM STREAM:apache WINDOW TUMBLING (X SECOND) GROUP BY host;
8787
```
8888

89-
Counts the number of records in 5 second window, grouped by host IP addresses.
89+
Counts the number of records in a five-second window, grouped by host IP addresses.
9090

91-
### MIN
91+
### `MIN`
9292

9393
```sql
9494
SELECT MIN(key) FROM STREAM:apache;
9595
```
9696

9797
Returns the minimum value of a key in a set of records.
9898

99-
### MAX
99+
### `MAX`
100100

101101
```sql
102102
SELECT MAX(key) FROM STREAM:apache;
103103
```
104104
Returns the maximum value of a key in a set of records.
105105

106-
### SUM
106+
### `SUM`
107107

108108
```sql
109109
SELECT SUM(key) FROM STREAM:apache;
@@ -115,15 +115,15 @@ Calculates the sum of all values of a key in a set of records.
115115

116116
Use time functions to add a new key with time data into a record.
117117

118-
### NOW
118+
### `NOW`
119119

120120
```sql
121121
SELECT NOW() FROM STREAM:apache;
122122
```
123123

124124
Adds the current system time to a record using the format `%Y-%m-%d %H:%M:%S`. Output example: `2019-03-09 21:36:05`.
125125

126-
### UNIX\_TIMESTAMP
126+
### `UNIX_TIMESTAMP`
127127

128128
```sql
129129
SELECT UNIX_TIMESTAMP() FROM STREAM:apache;
@@ -135,21 +135,21 @@ Adds the current Unix time to a record. Output example: `1552196165`.
135135

136136
Use record functions to append new keys to a record using values from the record's context.
137137

138-
### RECORD\_TAG
138+
### `RECORD_TAG`
139139

140140
```sql
141141
SELECT RECORD_TAG() FROM STREAM:apache;
142142
```
143143

144-
Append Tag string associated to the record as a new key.
144+
Append tag string associated to the record as a new key.
145145

146-
### RECORD\_TIME
146+
### `RECORD_TIME`
147147

148148
```sql
149149
SELECT RECORD_TIME() FROM STREAM:apache;
150150
```
151151

152-
## The WHERE condition
152+
## `WHERE` condition
153153

154154
Similar to conventional SQL statements, Fluent Bit supports the `WHERE` condition. You can use this condition in both keys and subkeys. For example:
155155

@@ -163,7 +163,7 @@ You can confirm whether a key exists in a record by using the record-specific fu
163163
SELECT MAX(key) FROM STREAM:apache WHERE @record.contains(key);
164164
```
165165

166-
And to check whether the value of a key is `NULL`:
166+
To determine if the value of a key is `NULL`:
167167

168168
```sql
169169
SELECT MAX(key) FROM STREAM:apache WHERE key IS NULL;

0 commit comments

Comments
 (0)