You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: development/library_api.md
+22-24Lines changed: 22 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -7,23 +7,21 @@
7
7
[Fluent Bit](http://fluentbit.io) runs as a service, meaning that the API exposed for developers provide interfaces to create and manage a context, specify inputs/outputs, set configuration parameters and set routing paths for the event/records. A typical usage of the library involves:
8
8
9
9
- Create library instance/context.
10
-
- Enable _input_ plugin(s) instances and set properties.
11
-
- Enable _output_ plugin(s) instances and set properties.
10
+
- Enable _input_ plugin(s) and set properties.
11
+
- Enable _output_ plugin(s) and set properties.
12
12
- Start the library runtime.
13
13
- Optionally ingest records manually.
14
14
- Stop the library runtime.
15
15
- Destroy library instance/context.
16
16
17
17
## Data Types
18
18
19
-
There are three main data types exposed by the library. All of them including further functions are prefixed with __flb\___. The following table describes them:
19
+
Starting from Fluent Bit v0.9, there is only one data type exposed by the library, by convention prefixed with __flb\___.
20
20
21
21
22
22
| Type | Description |
23
23
|--------------|----------------------|
24
24
| flb_ctx_t | Main library context. It aims to reference the context returned by _flb\_create();_|
25
-
| flb_input_t | Reference an enabled _input_ plugin instance. Used to store the output of _flb\_input(...);_ function. |
26
-
| flb_output_t | Reference an enabled _output_ plugin instance. Used to store the output of _flb\_output(...);_ function. |
27
25
28
26
## API Reference
29
27
@@ -62,7 +60,7 @@ When built, [Fluent Bit](http://fluentbit.io) library contains a certain number
The argument __ctx__ represents the library context created by __flb_create()__, then __name__ is the name of the input plugin that is required to enable.
@@ -71,14 +69,14 @@ The third argument __data__ can be used to pass a custom reference to the plugin
71
69
72
70
__Return Value__
73
71
74
-
On success, __flb_input()__ returns the input plugin instance; on error, it returns NULL.
72
+
On success, __flb_input()__ returns an integer value >= zero (similar to a file descriptor); on error, it returns NULL.
75
73
76
74
__Usage__
77
75
78
76
```C
79
-
flb_input_t *in;
77
+
int in_ffd;
80
78
81
-
in = flb_input(ctx, "cpu", NULL);
79
+
in_ffd = flb_input(ctx, "cpu", NULL);
82
80
```
83
81
84
82
### Set Input Plugin Properties
@@ -88,7 +86,7 @@ A plugin instance created through __flb_input()__, may provide some configuratio
88
86
__Prototype__
89
87
90
88
```C
91
-
intflb_input_set(flb_input_t *in, ...);
89
+
intflb_input_set(flb_ctx_t *ctx, int in_ffd, ...);
92
90
```
93
91
94
92
__Return Value__
@@ -102,13 +100,13 @@ The __flb_input_set()__ allow to set one or more properties in a key/value strin
102
100
```C
103
101
int ret;
104
102
105
-
ret = flb_input_set(in,
103
+
ret = flb_input_set(ctx, in_ffd,
106
104
"tag", "my_records",
107
105
"ssl", "false",
108
106
NULL);
109
107
```
110
108
111
-
The above example specified the values for the properties __tag__ and __ssl__, note that the value is always a string (char *) and once there is no more parameters a NULL argument must be added at the end of the list.
109
+
The argument __ctx__ represents the library context created by __flb_create()__. The above example specified the values for the properties __tag__ and __ssl__, note that the value is always a string (char *) and once there is no more parameters a NULL argument must be added at the end of the list.
112
110
113
111
The properties allowed per input plugin are specified on each specific plugin documentation.
114
112
@@ -121,7 +119,7 @@ When built, [Fluent Bit](http://fluentbit.io) library contains a certain number
The argument __ctx__ represents the library context created by __flb_create()__, then __name__ is the name of the output plugin that is required to enable.
@@ -135,9 +133,9 @@ On success, __flb_output()__ returns the output plugin instance; on error, it re
135
133
__Usage__
136
134
137
135
```C
138
-
flb_output_t *out;
136
+
int out_ffd;
139
137
140
-
out = flb_output(ctx, "stdout", NULL);
138
+
out_ffd = flb_output(ctx, "stdout", NULL);
141
139
```
142
140
143
141
### Set Output Plugin Properties
@@ -147,12 +145,12 @@ A plugin instance created through __flb_output()__, may provide some configurati
147
145
__Prototype__
148
146
149
147
```C
150
-
intflb_output_set(flb_output_t *in, ...);
148
+
intflb_output_set(flb_ctx_t *ctx, int out_ffd, ...);
151
149
```
152
150
153
151
__Return Value__
154
152
155
-
On success it returns 0; on error it returns a negative number.
153
+
On success it returns an integer value >= zero (similar to a file descriptor); on error it returns a negative number.
156
154
157
155
__Usage__
158
156
@@ -161,13 +159,13 @@ The __flb_output_set()__ allow to set one or more properties in a key/value stri
161
159
```C
162
160
int ret;
163
161
164
-
ret = flb_output_set(in,
165
-
"tag", "my_records",
166
-
"ssl", "false",
167
-
NULL);
162
+
ret = flb_output_set(ctx, out_ffd,
163
+
"tag", "my_records",
164
+
"ssl", "false",
165
+
NULL);
168
166
```
169
167
170
-
The above example specified the values for the properties __tag__ and __ssl__, note that the value is always a string (char *) and once there is no more parameters a NULL argument must be added at the end of the list.
168
+
The argument __ctx__ represents the library context created by __flb_create()__. The above example specified the values for the properties __tag__ and __ssl__, note that the value is always a string (char *) and once there is no more parameters a NULL argument must be added at the end of the list.
171
169
172
170
The properties allowed per output plugin are specified on each specific plugin documentation.
173
171
@@ -250,10 +248,10 @@ There are some cases where the caller application may want to ingest data into F
intflb_lib_push(flb_ctx_t *ctx, int in_ffd, void *data, size_t len);
254
252
```
255
253
256
-
The first argument __input__ is a reference to an input instance of the __lib__ plugin, __data__ is a reference to the message to be ingested and __len__ the number of bytes to take from it.
254
+
The first argument is the context created previously through __flb_create()__. __in_ffd__ is the numeric reference of the input plugin (for this case it should be an input of plugin __lib__ type), __data__ is a reference to the message to be ingested and __len__ the number of bytes to take from it.
0 commit comments