Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser_json: allow to parse int as a time value #8160

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nokute78
Copy link
Collaborator

Fixes #8154

This patch is to parse int value as a time value.

Example:
input:

{ "msg":"blah" , "time":1699558262 }

output:

[[1699558262.000000000, {}], {"msg"=>"blah", "container_id"=>"test"}]

Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • [N/A] Run local packaging test showing all targets (including any new ones) build.
  • [N/A] Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • [N/A] Documentation required for this feature

Backporting

  • Backport to latest stable release.

Configuration

[SERVICE]
    flush           1
    log_level       info
    parsers_file    b.conf

[INPUT]
    Name dummy
    Dummy {"log": "{ \"msg\":\"blah\" , \"time\":1699558262 }", "container_id": "test"}

[FILTER]
    Name parser
    Match *
    Key_Name log
    Parser json
    Reserve_Data True

[OUTPUT]
    Name                stdout
    Match               *
[PARSER]
    Name        json
    Time_Key    time
    Time_Format %s
    Format      json

Debug/Valgrind output

input:

{ "msg":"blah" , "time":1699558262 }

output:

[[1699558262.000000000, {}], {"msg"=>"blah", "container_id"=>"test"}]
$ valgrind --leak-check=full ~/git/fluent-bit/build/bin/fluent-bit -c a.conf 
==75879== Memcheck, a memory error detector
==75879== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==75879== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==75879== Command: /home/taka/git/fluent-bit/build/bin/fluent-bit -c a.conf
==75879== 
Fluent Bit v2.2.1
* Copyright (C) 2015-2023 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2023/11/11 10:57:54] [ info] [fluent bit] version=2.2.1, commit=281aea0a10, pid=75879
[2023/11/11 10:57:54] [ info] [storage] ver=1.2.0, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/11/11 10:57:54] [ info] [cmetrics] version=0.6.4
[2023/11/11 10:57:54] [ info] [ctraces ] version=0.3.1
[2023/11/11 10:57:54] [ info] [input:dummy:dummy.0] initializing
[2023/11/11 10:57:54] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
[2023/11/11 10:57:54] [ info] [output:stdout:stdout.0] worker #0 started
[2023/11/11 10:57:54] [ info] [sp] stream processor started
[0] dummy.0: [[1699558262.000000000, {}], {"msg"=>"blah", "container_id"=>"test"}]
[0] dummy.0: [[1699558262.000000000, {}], {"msg"=>"blah", "container_id"=>"test"}]
^C[2023/11/11 10:57:57] [engine] caught signal (SIGINT)
[2023/11/11 10:57:57] [ warn] [engine] service will shutdown in max 5 seconds
[0] dummy.0: [[1699558262.000000000, {}], {"msg"=>"blah", "container_id"=>"test"}]
[2023/11/11 10:57:57] [ info] [input] pausing dummy.0
[2023/11/11 10:57:58] [ info] [engine] service has stopped (0 pending tasks)
[2023/11/11 10:57:58] [ info] [input] pausing dummy.0
[2023/11/11 10:57:58] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2023/11/11 10:57:58] [ info] [output:stdout:stdout.0] thread worker #0 stopped
==75879== 
==75879== HEAP SUMMARY:
==75879==     in use at exit: 0 bytes in 0 blocks
==75879==   total heap usage: 1,947 allocs, 1,947 frees, 1,743,545 bytes allocated
==75879== 
==75879== All heap blocks were freed -- no leaks are possible
==75879== 
==75879== For lists of detected and suppressed errors, rerun with: -s
==75879== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

@daljitsharma
Copy link

Hi, any update on this PR?

@daljitsharma
Copy link

@nokute78 any timeline on when this will be merged?

@nokute78
Copy link
Collaborator Author

@edsiper @leonardo-albertovich Could you review this PR ?

@daljitsharma
Copy link

@edsiper @leonardo-albertovich any update on this?

@daljitsharma
Copy link

Hi, @edsiper @leonardo-albertovich any update on this?

@daljitsharma
Copy link

Hi, @edsiper @leonardo-albertovich @nokute78 any update on this?

@nikolaygs
Copy link

nikolaygs commented Jun 3, 2024

Hey Folks, do you have any update on merging this? @leonardo-albertovich @edsiper

@dsegurag
Copy link

up! I'm interested too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using JSON parser when Time_Key is integer
4 participants