diff --git a/collectors/googlestackdriver/collector.js b/collectors/googlestackdriver/collector.js index a641db26..1b872b43 100644 --- a/collectors/googlestackdriver/collector.js +++ b/collectors/googlestackdriver/collector.js @@ -107,13 +107,15 @@ timestamp < "${state.until}"`; let logs = result.data.entries || []; AlLogger.info(`Getting page: ${pagesRetireved + 1} Logs retrieved: ${logs.length}`); pagesRetireved++; - const nextPage = { ...params, pageToken: result.data.nextPageToken }; + const nextPageToken = result.data && result.data.nextPageToken ? result.data.nextPageToken : null; + let nextPage; + if (nextPageToken) { + nextPage = { ...params, filter: filter, pageToken: nextPageToken }; + } const newAcc = [...acc, ...logs]; AlLogger.info(`Total Logs ${newAcc.length}`); - - if (nextPage.pageToken && pagesRetireved < process.env.paws_max_pages_per_invocation) { - - return logging.entries.list(params) + if (nextPage && nextPage.pageToken && pagesRetireved < process.env.paws_max_pages_per_invocation) { + return logging.entries.list(nextPage) .then(res => { return paginationCallback(res, newAcc) }); @@ -123,7 +125,7 @@ timestamp < "${state.until}"`; }; const pageSize = state.pageSize > 0 ? state.pageSize : MAX_PAGE_SIZE; - let params = state.nextPage ? + let params = state.nextPage && state.nextPage.pageToken ? state.nextPage : { filter, @@ -134,10 +136,9 @@ timestamp < "${state.until}"`; logging.entries.list(params) .then(paginationCallback) .then(({ logs, nextPage }) => { - const newState = collector._getNextCollectionState(state, nextPage); + AlLogger.debug(`GSTA000012 NextCollectionState ${JSON.stringify(newState)}`); AlLogger.info(`GSTA000002 Next collection in ${newState.poll_interval_sec} seconds`); - return callback(null, logs, newState, newState.poll_interval_sec); }) .catch(err => { diff --git a/collectors/googlestackdriver/package.json b/collectors/googlestackdriver/package.json index 2ab38d29..f2f27602 100644 --- a/collectors/googlestackdriver/package.json +++ b/collectors/googlestackdriver/package.json @@ -1,6 +1,6 @@ { "name": "googlestackdriver-collector", - "version": "1.2.12", + "version": "1.2.13", "description": "Alert Logic AWS based Googlestackdriver Log Collector", "repository": {}, "private": true, diff --git a/ps_spec.yml b/ps_spec.yml index 0b3e557c..bb85d77a 100644 --- a/ps_spec.yml +++ b/ps_spec.yml @@ -177,7 +177,7 @@ stages: - ./build_collector.sh googlestackdriver env: ALPS_SERVICE_NAME: "paws-googlestackdriver-collector" - ALPS_SERVICE_VERSION: "1.2.12" #set the value from collector package json + ALPS_SERVICE_VERSION: "1.2.13" #set the value from collector package json outputs: file: ./googlestackdriver-collector* packagers: