/src/fluent-bit/include/fluent-bit/flb_storage.h
Line | Count | Source |
1 | | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* Fluent Bit |
4 | | * ========== |
5 | | * Copyright (C) 2015-2026 The Fluent Bit Authors |
6 | | * |
7 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
8 | | * you may not use this file except in compliance with the License. |
9 | | * You may obtain a copy of the License at |
10 | | * |
11 | | * http://www.apache.org/licenses/LICENSE-2.0 |
12 | | * |
13 | | * Unless required by applicable law or agreed to in writing, software |
14 | | * distributed under the License is distributed on an "AS IS" BASIS, |
15 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | | * See the License for the specific language governing permissions and |
17 | | * limitations under the License. |
18 | | */ |
19 | | |
20 | | #ifndef FLB_STORAGE_H |
21 | | #define FLB_STORAGE_H |
22 | | |
23 | | #include <fluent-bit/flb_info.h> |
24 | | #include <chunkio/chunkio.h> |
25 | | #include <chunkio/cio_stats.h> |
26 | | |
27 | | #include <inttypes.h> |
28 | | |
29 | | /* Storage type */ |
30 | 2.06k | #define FLB_STORAGE_FS CIO_STORE_FS /* 0 */ |
31 | 1.73k | #define FLB_STORAGE_MEM CIO_STORE_MEM /* 1 */ |
32 | 2.22k | #define FLB_STORAGE_MEMRB 10 |
33 | | |
34 | | /* Storage defaults */ |
35 | 102 | #define FLB_STORAGE_BL_MEM_LIMIT "100M" |
36 | 1.73k | #define FLB_STORAGE_MAX_CHUNKS_UP 128 |
37 | | |
38 | | struct flb_storage_metrics { |
39 | | int fd; |
40 | | |
41 | | struct cmt *cmt; |
42 | | |
43 | | /* cmetrics */ |
44 | | struct cmt_gauge *cmt_chunks; /* total number of chunks */ |
45 | | struct cmt_gauge *cmt_mem_chunks; /* number of chunks up in memory */ |
46 | | struct cmt_gauge *cmt_fs_chunks; /* total number of filesystem chunks */ |
47 | | struct cmt_gauge *cmt_fs_chunks_up; /* number of filesystem chunks up in memory */ |
48 | | struct cmt_gauge *cmt_fs_chunks_down; /* number of filesystem chunks down */ |
49 | | }; |
50 | | |
51 | | /* |
52 | | * The storage structure helps to associate the contexts between |
53 | | * input instances and the chunkio context and further streams. |
54 | | * |
55 | | * Each input instance have a stream associated. |
56 | | */ |
57 | | struct flb_storage_input { |
58 | | int type; /* CIO_STORE_FS | CIO_STORE_MEM */ |
59 | | struct cio_stream *stream; |
60 | | struct cio_ctx *cio; |
61 | | }; |
62 | | |
63 | | static inline char *flb_storage_get_type(int type) |
64 | 4 | { |
65 | 4 | switch(type) { |
66 | 0 | case FLB_STORAGE_FS: |
67 | 0 | return "'filesystem' (memory + filesystem)"; |
68 | 4 | case FLB_STORAGE_MEM: |
69 | 4 | return "'memory' (memory only)"; |
70 | 0 | case FLB_STORAGE_MEMRB: |
71 | 0 | return "'memrb' (memory ring buffer)"; |
72 | 4 | }; |
73 | |
|
74 | | return NULL; |
75 | 4 | } Unexecuted instantiation: flb_chunk_trace.c:flb_storage_get_type flb_input.c:flb_storage_get_type Line | Count | Source | 64 | 4 | { | 65 | 4 | switch(type) { | 66 | 0 | case FLB_STORAGE_FS: | 67 | 0 | return "'filesystem' (memory + filesystem)"; | 68 | 4 | case FLB_STORAGE_MEM: | 69 | 4 | return "'memory' (memory only)"; | 70 | 0 | case FLB_STORAGE_MEMRB: | 71 | 0 | return "'memrb' (memory ring buffer)"; | 72 | 4 | }; | 73 | |
| 74 | | return NULL; | 75 | 4 | } |
Unexecuted instantiation: flb_input_chunk.c:flb_storage_get_type Unexecuted instantiation: flb_engine.c:flb_storage_get_type Unexecuted instantiation: flb_storage.c:flb_storage_get_type Unexecuted instantiation: flb_metrics_exporter.c:flb_storage_get_type Unexecuted instantiation: emitter.c:flb_storage_get_type Unexecuted instantiation: sb.c:flb_storage_get_type Unexecuted instantiation: ml.c:flb_storage_get_type Unexecuted instantiation: ml_concat.c:flb_storage_get_type Unexecuted instantiation: rewrite_tag.c:flb_storage_get_type Unexecuted instantiation: log_to_metrics.c:flb_storage_get_type Unexecuted instantiation: input_fuzzer.c:flb_storage_get_type |
76 | | |
77 | | struct flb_input_instance; |
78 | | |
79 | | int flb_storage_create(struct flb_config *ctx); |
80 | | int flb_storage_input_create(struct cio_ctx *cio, |
81 | | struct flb_input_instance *in); |
82 | | void flb_storage_destroy(struct flb_config *ctx); |
83 | | void flb_storage_input_destroy(struct flb_input_instance *in); |
84 | | |
85 | | struct flb_storage_metrics *flb_storage_metrics_create(struct flb_config *ctx); |
86 | | |
87 | | /* cmetrics */ |
88 | | int flb_storage_metrics_update(struct flb_config *config, struct flb_storage_metrics *sm); |
89 | | |
90 | | void flb_storage_chunk_count(struct flb_config *ctx, int *mem_chunks, int *fs_chunks); |
91 | | |
92 | | /* DLQ */ |
93 | | int flb_storage_quarantine_chunk(struct flb_config *ctx, |
94 | | struct cio_chunk *ch, |
95 | | const char *tag, |
96 | | int status_code, |
97 | | const char *out_name); |
98 | | |
99 | | #endif |