Commit ca2a6a5
committed
pack: add metadata and group info into log JSON record (fix #10258)
Before this patch, the JSON log record encoder only supported the log
record body as an output content, missing support for log record metadata
and group metadata and group attributes (if defined).
This patch makes the JSON encoder add support for the missing data, packaging into
the record a new parent key called '__internal__' that holds the following inside it:
- group_attributes: group header attributes
- log_metadata: log record metadata
Note that for cases where the origin of the data was OTLP and as part of the groups
we add 'group metadata' (in the origin), this is not being used since it only contains
internal references that are not used for this JSON export: we do not aim to reassmble
this JSON into a Fluent Bit record.
Consider the following original OTLP JSON record ingested into the pipeline:
{
"resourceLogs": [
{
"resource": {
"attributes": [
{
"key": "service.name",
"value": {
"stringValue": "my.service"
}
}
]
},
"scopeLogs": [
{
"scope": {
"name": "my.library",
"version": "1.0.0",
"attributes": [
{
"key": "my.scope.attribute",
"value": {
"stringValue": "some scope attribute"
}
}
]
},
"logRecords": [
{
"timeUnixNano": "1544712660300000000",
"observedTimeUnixNano": "1544712660300000000",
"severityNumber": 10,
"severityText": "Information",
"traceId": "5B8EFFF798038103D269B633813FC60C",
"spanId": "EEE19B7EC3C1B174",
"body": {
"stringValue": "Example log record"
},
"attributes": [
{
"key": "string.attribute",
"value": {
"stringValue": "some string"
}
},
{
"key": "boolean.attribute",
"value": {
"boolValue": true
}
},
{
"key": "int.attribute",
"value": {
"intValue": "10"
}
},
{
"key": "double.attribute",
"value": {
"doubleValue": 637.704
}
},
{
"key": "array.attribute",
"value": {
"arrayValue": {
"values": [
{
"stringValue": "many"
},
{
"stringValue": "values"
}
]
}
}
},
{
"key": "map.attribute",
"value": {
"kvlistValue": {
"values": [
{
"key": "some.map.key",
"value": {
"stringValue": "some value"
}
}
]
}
}
}
]
}
],
"schemaUrl": "https://example.com/schema"
}
],
"schemaUrl": "https://example.com/schema"
}
]
}
now when encoded in msgpack and then JSON the output will be:
{
"date": 1544712658.274599,
"__internal__": {
"group_attributes": {
"resource": {
"attributes": {
"service.name": "my.service"
}
},
"scope": {
"name": "my.library",
"version": "1.0.0",
"attributes": {
"my.scope.attribute": "some scope attribute"
}
}
},
"log_metadata": {
"otlp": {
"observed_timestamp": 1544712660300000000,
"severity_number": 10,
"severity_text": "Information",
"attributes": {
"string.attribute": "some string",
"boolean.attribute": true,
"int.attribute": 10,
"double.attribute": 637.704,
"array.attribute": [
"many",
"values"
],
"map.attribute": {
"some.map.key": "some value"
}
},
"trace_id": "5B8EFFF798038103D269B633813FC60C",
"span_id": "EEE19B7EC3C1B174"
}
}
},
"log": "Example log record"
}
Signed-off-by: Eduardo Silva <[email protected]>1 parent 757b13d commit ca2a6a5
1 file changed
+113
-52
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| |||
917 | 920 | | |
918 | 921 | | |
919 | 922 | | |
920 | | - | |
921 | | - | |
922 | | - | |
923 | | - | |
| 923 | + | |
924 | 924 | | |
925 | 925 | | |
926 | 926 | | |
927 | 927 | | |
928 | | - | |
929 | | - | |
930 | | - | |
931 | 928 | | |
932 | 929 | | |
933 | | - | |
934 | 930 | | |
935 | 931 | | |
936 | 932 | | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
937 | 938 | | |
938 | 939 | | |
939 | 940 | | |
| |||
949 | 950 | | |
950 | 951 | | |
951 | 952 | | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
952 | 962 | | |
953 | 963 | | |
954 | 964 | | |
| |||
960 | 970 | | |
961 | 971 | | |
962 | 972 | | |
963 | | - | |
964 | | - | |
965 | | - | |
966 | | - | |
967 | | - | |
968 | | - | |
| 973 | + | |
| 974 | + | |
969 | 975 | | |
970 | 976 | | |
971 | | - | |
972 | | - | |
973 | | - | |
974 | | - | |
975 | | - | |
976 | | - | |
977 | | - | |
978 | | - | |
979 | | - | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
980 | 982 | | |
| 983 | + | |
981 | 984 | | |
982 | | - | |
983 | | - | |
984 | | - | |
985 | | - | |
986 | | - | |
987 | | - | |
988 | | - | |
989 | | - | |
990 | | - | |
| 985 | + | |
| 986 | + | |
991 | 987 | | |
| 988 | + | |
992 | 989 | | |
993 | | - | |
994 | | - | |
995 | | - | |
996 | | - | |
997 | | - | |
| 990 | + | |
998 | 991 | | |
999 | | - | |
1000 | 992 | | |
1001 | 993 | | |
1002 | 994 | | |
| |||
1011 | 1003 | | |
1012 | 1004 | | |
1013 | 1005 | | |
1014 | | - | |
| 1006 | + | |
1015 | 1007 | | |
1016 | 1008 | | |
1017 | 1009 | | |
| |||
1020 | 1012 | | |
1021 | 1013 | | |
1022 | 1014 | | |
1023 | | - | |
| 1015 | + | |
1024 | 1016 | | |
1025 | 1017 | | |
1026 | 1018 | | |
| |||
1033 | 1025 | | |
1034 | 1026 | | |
1035 | 1027 | | |
1036 | | - | |
1037 | | - | |
1038 | | - | |
1039 | | - | |
1040 | | - | |
1041 | | - | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
1042 | 1099 | | |
1043 | 1100 | | |
1044 | 1101 | | |
| |||
1071 | 1128 | | |
1072 | 1129 | | |
1073 | 1130 | | |
1074 | | - | |
| 1131 | + | |
1075 | 1132 | | |
1076 | 1133 | | |
1077 | 1134 | | |
| |||
1084 | 1141 | | |
1085 | 1142 | | |
1086 | 1143 | | |
1087 | | - | |
| 1144 | + | |
1088 | 1145 | | |
1089 | 1146 | | |
1090 | 1147 | | |
| |||
1102 | 1159 | | |
1103 | 1160 | | |
1104 | 1161 | | |
1105 | | - | |
| 1162 | + | |
1106 | 1163 | | |
1107 | 1164 | | |
1108 | 1165 | | |
| |||
1113 | 1170 | | |
1114 | 1171 | | |
1115 | 1172 | | |
1116 | | - | |
1117 | | - | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
1118 | 1180 | | |
1119 | 1181 | | |
1120 | 1182 | | |
1121 | 1183 | | |
1122 | 1184 | | |
1123 | | - | |
1124 | 1185 | | |
1125 | 1186 | | |
1126 | 1187 | | |
| |||
0 commit comments