mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Fleet] Fix updating task interval for agent log usage (#148635)
This commit is contained in:
parent
b437fd54b8
commit
7d2428430d
1 changed files with 15 additions and 2 deletions
|
@ -56,12 +56,25 @@ export async function startFleetUsageLogger(taskManager: TaskManagerStartContrac
|
|||
if (!isInfoLogLevelEnabled) {
|
||||
return;
|
||||
}
|
||||
appContextService.getLogger().info(`Task ${TASK_ID} scheduled with interval 5m`);
|
||||
const interval = isDebugLogLevelEnabled ? '5m' : '15m';
|
||||
|
||||
// Re-schedule the task if interval changed
|
||||
const task = await taskManager?.get(TASK_ID).catch((err) => {
|
||||
if (err.output.statusCode === 404) {
|
||||
return null;
|
||||
}
|
||||
|
||||
throw err;
|
||||
});
|
||||
if (task?.schedule?.interval !== interval) {
|
||||
await taskManager?.removeIfExists(TASK_ID);
|
||||
}
|
||||
appContextService.getLogger().info(`Task ${TASK_ID} scheduled with interval ${interval}`);
|
||||
await taskManager?.ensureScheduled({
|
||||
id: TASK_ID,
|
||||
taskType: TASK_TYPE,
|
||||
schedule: {
|
||||
interval: isDebugLogLevelEnabled ? '5m' : '15m',
|
||||
interval,
|
||||
},
|
||||
scope: ['fleet'],
|
||||
state: {},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue