diff --git a/packages/flare/src/main/resources/splunk/default/inputs.conf b/packages/flare/src/main/resources/splunk/default/inputs.conf index 1ba716d..b50d06f 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 = 600 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 bd5772a..c263115 100644 --- a/packages/react-components/src/utils/setupConfiguration.ts +++ b/packages/react-components/src/utils/setupConfiguration.ts @@ -114,8 +114,27 @@ async function saveConfiguration( `${isIngestingMetadataOnly}` ); await saveIndexForIngestion(service, indexName); + const isFirstConfiguration = await fetchIsFirstConfiguration(); + if (isFirstConfiguration) { + await updateEventIngestionCronJobInterval(service, 1); + } await completeSetup(service); await reloadApp(service); + if (isFirstConfiguration) { + await updateEventIngestionCronJobInterval(service, 600); + await reloadApp(service); + } +} + +async function updateEventIngestionCronJobInterval(service: SplunkService, intervalInSeconds: number): Promise { + await updateConfigurationFile( + service, + 'inputs', + 'script://$SPLUNK_HOME/etc/apps/flare/bin/cron_job_ingest_events.py', + { + interval: `${intervalInSeconds}`, + } + ); } async function fetchCollectionItems(): Promise { @@ -178,15 +197,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, {}); @@ -218,6 +230,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(