Files metrics - Fluent Bit

Description

Tracks files (yaml files, jpg pictures etc.) sent to their destinations (s3, minio etc.). We can then delete files locally when they have been sent to all their storage destinations.

It loads a Fluent Bit plugin we wrote ourselves to do this task, located in the fluent_bit_plugins package.

It creates a table on the database (currently PostgreSQL only) to store each file status.

erDiagram
    files_metrics {
        integer id
        timestamp timestamp
        text robot_name
        text robot_id
        text group_name
        double duration
        text local_path
        text remote_path
        bool uploaded
        bool on_filesystem
        bool deleted
        bool ignored
        text storage_type
        text content_type
        integer size
        timestamp created_at
        timestamp updated_at
    }

Parameters

ParameterDescriptionTypeDefault
db_typeDatabase used.str"pgsql"
file_storageWhere data will be stored.list[str](s3, minio)N/A (Mandatory)
delete_when_sentDelete file when sent.booltrue
minio.access_key_idMinio Access key ID.strN/A (Mandatory)
minio.bucketMinio bucket name.str"dc_bucket"
minio.endpointMinio endpoint.str"127.0.0.1:9000"
minio.secret_access_keyMinio Secret access key.strN/A (Mandatory)
minio.src_fieldsJSON fields containing local paths for Minio.strN/A (Mandatory)
minio.upload_fieldsJSON fields containing remote paths for Minio.strN/A (Mandatory)
minio.use_sslUse SSL for Minio.booltrue
plugin_pathShared library path compiled by go.str"{package_share_directory}/flb_plugins/lib/out_files_metrics.so"
pgsql.databaseDatabase name to connect to.str<system_username>
pgsql.hostHostname/IP address of the PostgreSQL instance.str"127.0.0.1"
pgsql.passwordPassword of PostgreSQL username.str""
pgsql.portPostgreSQL port.str"5432"
pgsql.sslUse ssl for PostgreSQL connection.booltrue
pgsql.tableTable name where to store data.str"pg_table"
pgsql.userPostgreSQL username.str<system_username>
plugin_pathShared library of the plugin.str<install_path>/lib/out_files_metrics.so
s3.access_key_idS3 Access key ID.strN/A (Mandatory)
s3.bucketS3 bucket name.strN/A (Mandatory)
s3.endpointS3 endpoint.strN/A (Mandatory)
s3.secret_access_keyS3 Secret access key.strN/A (Mandatory)
s3.src_fieldsJSON fields containing local paths for s3.strN/A (Mandatory)
s3.upload_fieldsJSON fields containing remote paths for S3.strN/A (Mandatory)

Example

flb_files_metrics:
    plugin: "dc_destinations/FlbFilesMetrics"
    inputs: ["/dc/group/map"]
    file_storage: ["minio", "s3"]
    db_type: "pgsql"
    debug: true
    delete_when_sent: true
    minio:
        endpoint: 127.0.0.1:9000
        access_key_id: XEYqG4ZcPY5jiq5i
        secret_access_key: ji011KCtI82ZeQS6UwsQAg8x9VR4lSaQ
        use_ssl: false
        bucket: "mybucket"
        src_fields: ["map.local_paths.pgm", "map.local_paths.yaml"]
        upload_fields: ["map.minio_paths.pgm", "map.minio_paths.yaml"]
    s3:
        endpoint: 127.0.0.1:9000
        access_key_id: XEYqG4ZcPY5jiq5i
        secret_access_key: ji011KCtI82ZeQS6UwsQAg8x9VR4lSaQ
        bucket: "mybucket"
        src_fields: ["map.local_paths.yaml"]
        upload_fields: ["map.s3_paths.yaml"]
    pgsql:
        host: "127.0.0.1"
        port: "5432"
        user: fluentbit
        password: password
        database: "fluentbit"
        table: "files_metrics"
        timestamp_key: "date"
        time_format: "double"
        time_key: "date"
        ssl: false