Skip to content

Commit 5256604

Browse files
authored
[Ingest Manager] Manually build Fleet kuery with Node arguments (#76589)
1 parent 2994d32 commit 5256604

File tree

2 files changed

+17
-15
lines changed
  • src/plugins/data/common/es_query/kuery/node_types
  • x-pack/plugins/ingest_manager/server/services/agents

2 files changed

+17
-15
lines changed

src/plugins/data/common/es_query/kuery/node_types/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export interface NamedArgTypeBuildNode {
7676
}
7777

7878
interface WildcardType {
79+
wildcardSymbol: string;
7980
buildNode: (value: string) => WildcardTypeBuildNode | KueryNode;
8081
test: (node: any, string: string) => boolean;
8182
toElasticsearchQuery: (node: any) => string;

x-pack/plugins/ingest_manager/server/services/agents/actions.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,19 @@ export async function getAgentActionsForCheckin(
7474
const filter = nodeTypes.function.buildNode('and', [
7575
nodeTypes.function.buildNode(
7676
'not',
77-
nodeTypes.function.buildNode(
78-
'is',
79-
`${AGENT_ACTION_SAVED_OBJECT_TYPE}.attributes.sent_at`,
80-
'*'
81-
)
82-
),
83-
nodeTypes.function.buildNode(
84-
'is',
85-
`${AGENT_ACTION_SAVED_OBJECT_TYPE}.attributes.agent_id`,
86-
agentId
77+
nodeTypes.function.buildNodeWithArgumentNodes('is', [
78+
nodeTypes.literal.buildNode(`${AGENT_ACTION_SAVED_OBJECT_TYPE}.attributes.sent_at`),
79+
nodeTypes.wildcard.buildNode(nodeTypes.wildcard.wildcardSymbol),
80+
nodeTypes.literal.buildNode(false),
81+
])
8782
),
83+
nodeTypes.function.buildNodeWithArgumentNodes('is', [
84+
nodeTypes.literal.buildNode(`${AGENT_ACTION_SAVED_OBJECT_TYPE}.attributes.agent_id`),
85+
nodeTypes.literal.buildNode(agentId),
86+
nodeTypes.literal.buildNode(false),
87+
]),
8888
]);
89+
8990
const res = await soClient.find<AgentActionSOAttributes>({
9091
type: AGENT_ACTION_SAVED_OBJECT_TYPE,
9192
filter,
@@ -176,11 +177,11 @@ export async function getNewActionsSince(soClient: SavedObjectsClientContract, t
176177
const filter = nodeTypes.function.buildNode('and', [
177178
nodeTypes.function.buildNode(
178179
'not',
179-
nodeTypes.function.buildNode(
180-
'is',
181-
`${AGENT_ACTION_SAVED_OBJECT_TYPE}.attributes.sent_at`,
182-
'*'
183-
)
180+
nodeTypes.function.buildNodeWithArgumentNodes('is', [
181+
nodeTypes.literal.buildNode(`${AGENT_ACTION_SAVED_OBJECT_TYPE}.attributes.sent_at`),
182+
nodeTypes.wildcard.buildNode(nodeTypes.wildcard.wildcardSymbol),
183+
nodeTypes.literal.buildNode(false),
184+
])
184185
),
185186
nodeTypes.function.buildNode(
186187
'range',

0 commit comments

Comments
 (0)