diff --git a/packages/flare/src/main/resources/splunk/default/inputs.conf b/packages/flare/src/main/resources/splunk/default/inputs.conf index 1ba716d..cf2fb4d 100644 --- a/packages/flare/src/main/resources/splunk/default/inputs.conf +++ b/packages/flare/src/main/resources/splunk/default/inputs.conf @@ -1,5 +1,5 @@ [script://$SPLUNK_HOME/etc/apps/flare/bin/cron_job_ingest_events.py] -interval = * * * * * +interval = 0 0 1 1 * python.version = python3 index = flare source = flare diff --git a/packages/react-components/src/utils/setupConfiguration.ts b/packages/react-components/src/utils/setupConfiguration.ts index 96e1068..147e2be 100644 --- a/packages/react-components/src/utils/setupConfiguration.ts +++ b/packages/react-components/src/utils/setupConfiguration.ts @@ -117,6 +117,10 @@ async function saveConfiguration( `${isIngestingMetadataOnly}` ); await saveIndexForIngestion(service, indexName); + const isFirstConfiguration = await fetchIsFirstConfiguration(); + if (isFirstConfiguration) { + await updateEventIngestionCronJobInterval(service, '1'); + } await updateSavedSearchQuery( service, flareSavedSearchName, @@ -124,6 +128,24 @@ async function saveConfiguration( ); await completeSetup(service); await reloadApp(service); + if (isFirstConfiguration) { + await updateEventIngestionCronJobInterval(service, '* * * * *'); + await reloadApp(service); + } +} + +async function updateEventIngestionCronJobInterval( + service: SplunkService, + interval: string +): Promise { + await updateConfigurationFile( + service, + 'inputs', + 'script://$SPLUNK_HOME/etc/apps/flare/bin/cron_job_ingest_events.py', + { + interval: `${interval}`, + } + ); } async function updateSavedSearchQuery( @@ -200,15 +222,8 @@ async function fetchIngestMetadataOnly(): Promise { async function createFlareIndex(): Promise { const service = createService(); - const isConfigured = - (await getConfigurationStanzaValue( - service, - 'app', - 'install', - 'is_configured', - 'unknown' - )) === '1'; - if (!isConfigured) { + const isFirstConfiguration = await fetchIsFirstConfiguration(); + if (isFirstConfiguration) { const currentIndexNames = await fetchAvailableIndexNames(); if (!currentIndexNames.find((indexName) => indexName === appName)) { await service.indexes().create(appName, {}); @@ -240,6 +255,19 @@ async function fetchAvailableIndexNames(): Promise> { return indexNames; } +async function fetchIsFirstConfiguration(): Promise { + const service = createService(); + return ( + (await getConfigurationStanzaValue( + service, + 'app', + 'install', + 'is_configured', + 'unknown' + )) !== '1' + ); +} + async function fetchCurrentIndexName(): Promise { const service = createService(); return getConfigurationStanzaValue(