summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/plugins/in_kubernetes_events/kubernetes_events.h
blob: 3afd48570fa75d6a18076483d9c723d8928b7e6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*  Fluent Bit
 *  ==========
 *  Copyright (C) 2015-2023 The Fluent Bit Authors
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#ifndef FLB_IN_KUBERNETES_EVENTS_H
#define FLB_IN_KUBERNETES_EVENTS_H

#include <fluent-bit/flb_input_plugin.h>
#include <fluent-bit/flb_info.h>
#include <fluent-bit/flb_upstream.h>
#include <fluent-bit/flb_record_accessor.h>
#include <fluent-bit/flb_sqldb.h>

#define DEFAULT_INTERVAL_SEC "0"
#define DEFAULT_INTERVAL_NSEC "500000000"

/* Filter context */
struct k8s_events {
    int coll_id;
    int coll_cleanup_id;
    int interval_sec;             /* interval collection time (Second)     */
    int interval_nsec;            /* interval collection time (Nanosecond) */
    int retention_time;           /* retention time limit, default 1 hour */

    /* Configuration parameters */
    char *api_host;
    int api_port;
    int api_https;
    int tls_debug;
    int tls_verify;
    int kube_token_ttl;
    flb_sds_t namespace;

    /* API Server end point */
    char kube_url[1024];

    /* TLS CA certificate file */
    char *tls_ca_path;
    char *tls_ca_file;

    /* TLS virtual host (optional), set by configmap */
    flb_sds_t tls_vhost;

    /* Kubernetes Token from FLB_KUBE_TOKEN file */
    char *token_file;
    char *token;
    int token_ttl;
    size_t token_len;
    int token_created;

    /* Pre-formatted HTTP Authorization header value */
    char *auth;
    size_t auth_len;

    int dns_retries;
    int dns_wait_time;

    struct flb_tls *tls;

    struct flb_log_event_encoder *encoder;

    /* record accessor */
    struct flb_record_accessor *ra_timestamp;
    struct flb_record_accessor *ra_resource_version;

    /* others */
    struct flb_config *config;
    struct flb_upstream *upstream;
    struct flb_input_instance *ins;

    /* limit for event queries */
    int limit_request;
    /* last highest seen resource_version */
    uint64_t last_resource_version;

#ifdef FLB_HAVE_SQLDB
    /* State database */
    struct flb_sqldb *db;
    int db_sync;
    int db_locking;
    flb_sds_t db_journal_mode;
    sqlite3_stmt *stmt_get_kubernetes_event_exists_by_uid;
    sqlite3_stmt *stmt_insert_kubernetes_event;
    sqlite3_stmt *stmt_delete_old_kubernetes_events;
#endif

    /* concurrency lock */
    pthread_mutex_t lock;
};

#endif