Skip to content

Commit

Permalink
servicenow: truncate very long field values (elastic#11982)
Browse files Browse the repository at this point in the history
It seems that some people store very long string values in servicenow
tables, resulting in failure to ingest. This change truncates those
fields to fit within the field length limit.
  • Loading branch information
efd6 authored Dec 4, 2024
1 parent 5866714 commit ba2aab7
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/servicenow/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# newer versions go on top
- version: "0.5.0"
changes:
- description: Truncate very long field values.
type: enhancement
link: https://github.com/elastic/integrations/pull/11982
- version: "0.4.0"
changes:
- description: Replace dropdown with the textbox for the timezone offset parameter.
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3285,6 +3285,28 @@ processors:
return false;
}
drop(ctx);
- script:
tag: script_to_truncate_long_fields
lang: painless
description: Truncate fields that are over length.
source: |-
def filterMassive(def src) {
if (src instanceof Map) {
for (def entry: src.entrySet()) {
entry.setValue(filterMassive(entry.getValue()));
}
return src;
} else if (src instanceof List) {
for (int i = 0; i < src.length; i++) {
src[i] = filterMassive(src[i]);
}
return src;
} else if (src instanceof String && src.length() > 32766) {
return src.substring(0, 32700)+' (truncated)';
}
return src;
}
filterMassive(ctx);
- set:
field: event.kind
tag: set_pipeline_error_into_event_kind
Expand Down
2 changes: 1 addition & 1 deletion packages/servicenow/manifest.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
format_version: 3.2.1
name: servicenow
title: "ServiceNow"
version: 0.4.0
version: 0.5.0
description: "Collect logs from ServiceNow with Elastic Agent."
type: integration
categories:
Expand Down

0 comments on commit ba2aab7

Please sign in to comment.