File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed
data_stream/prompt_response_logs/elasticsearch/ingest_pipeline Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 11# newer versions go on top
22- version : " 1.4.0-next"
33 changes :
4+ - description : Update the mapping to snake case in pipeline.
5+ type : enhancement
6+ link : https://github.com/elastic/integrations/pull/15604
47 - description : Add support for Vertex AI Prompt Response Logs datastream.
58 type : enhancement
69 link : https://github.com/elastic/integrations/pull/15435
Original file line number Diff line number Diff line change @@ -37,7 +37,41 @@ processors:
3737 field : event.action
3838 copy_from : gcp.vertexai.prompt_response_logs.api_method
3939 if : ctx.gcp?.vertexai?.prompt_response_logs?.api_method != null
40-
40+
41+ # Rename camelCase fields to snake_case
42+
43+ - script :
44+ lang : painless
45+ source : |
46+ Map keysToSnakeCase(Map m) {
47+ def regex = /_?([a-z])([A-Z]+)/;
48+ def snakeCaseMap = [:];
49+ for (entry in m.entrySet()) {
50+ def k = entry.getKey();
51+ def v = entry.getValue();
52+ if (v instanceof Map) {
53+ v = keysToSnakeCase(v);
54+ } else if (v instanceof List) {
55+ for (int i = 0; i < v.size(); i++) {
56+ def item = v.get(i);
57+ if (item instanceof Map) {
58+ v.set(i, keysToSnakeCase(item));
59+ }
60+ }
61+ }
62+ k = regex.matcher(k).replaceAll('$1_$2').toLowerCase();
63+ snakeCaseMap.put(k, v);
64+ }
65+ return snakeCaseMap;
66+ }
67+
68+ if (ctx.gcp?.vertexai?.prompt_response_logs?.full_request != null) {
69+ ctx.gcp.vertexai.prompt_response_logs.full_request = keysToSnakeCase(ctx.gcp.vertexai.prompt_response_logs.full_request);
70+ }
71+ if (ctx.gcp?.vertexai?.prompt_response_logs?.full_response != null) {
72+ ctx.gcp.vertexai.prompt_response_logs.full_response = keysToSnakeCase(ctx.gcp.vertexai.prompt_response_logs.full_response);
73+ }
74+
4175
4276 # Remove null and empty values recursively
4377 - script :
You can’t perform that action at this time.
0 commit comments