Increase idle timeout for connectors to 5 minutes (#175681)

## Summary

Update the logic to mark sync jobs as "idle":

Before any job (Crawler/Connector) would be marked as "idle" after 1
minute. This amount is too low, and we want to increase it to 5 minutes.
See similar change in connectors:
https://github.com/elastic/connectors/pull/2090

What it means in practice is that the summary of "idle" jobs will
account crawler jobs as idle after 1 minute of no progress (no change)
and connector sync jobs as idle after 5 minutes.

In practice it affects only this screen (see `Idle syncs`):

<img width="1346" alt="image"
src="21ae9837-7aa8-494d-a8b1-78948810d1f3">

Because timeouts are different, I had to modify the query that populates
the screen for all connectors + crawler to reflect that timeout is
different depending on service type.

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Artem Shelkovnikov 2024-02-13 12:17:12 +01:00 committed by GitHub
parent db08fb5c5b
commit 78f61714ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 35 additions and 63 deletions

View file

@ -123,15 +123,29 @@ export const ConnectorStats: React.FC<ConnectorStatsProps> = ({ isCrawler }) =>
</EuiSplitPanel.Inner>
<EuiSplitPanel.Inner grow={false} color="subdued">
{i18n.translate('xpack.enterpriseSearch.connectorStats.idleSyncsOrphanedSyncsLabel', {
defaultMessage:
'{idleCount} Idle syncs / {orphanedCount} Orphaned syncs / {errorCount} Sync errors',
values: {
errorCount: data?.errors || 0,
idleCount: data?.idle,
orphanedCount: data?.orphaned_jobs,
},
})}
{isCrawler
? i18n.translate(
'xpack.enterpriseSearch.connectorStats.crawlerSyncsOrphanedSyncsLabel',
{
defaultMessage: '{orphanedCount} Orphaned syncs / {errorCount} Sync errors',
values: {
errorCount: data?.errors || 0,
orphanedCount: data?.orphaned_jobs,
},
}
)
: i18n.translate(
'xpack.enterpriseSearch.connectorStats.connectorSyncsOrphanedSyncsLabel',
{
defaultMessage:
'{idleCount} Idle syncs / {orphanedCount} Orphaned syncs / {errorCount} Sync errors',
values: {
errorCount: data?.errors || 0,
idleCount: data?.idle,
orphanedCount: data?.orphaned_jobs,
},
}
)}
</EuiSplitPanel.Inner>
</EuiSplitPanel.Outer>
</EuiFlexItem>

View file

@ -42,10 +42,15 @@ export const fetchSyncJobsStats = async (
query: getInProgressJobsCountQuery(isCrawler),
});
const idleJobsCountResponse = await client.asCurrentUser.count({
index: CONNECTORS_JOBS_INDEX,
query: getIdleJobsCountQuery(isCrawler),
});
// Idle syncs don't make sense for Crawler, because it does not have concept of "Idle" syncs at all.
// We tried tracking idle syncs in a way similar to connectors, but it results in all crawler jobs
// marked as idle.
const idleJobsCountResponse = isCrawler
? undefined
: await client.asCurrentUser.count({
index: CONNECTORS_JOBS_INDEX,
query: getIdleJobsCountQuery(),
});
const errorResponse = await client.asCurrentUser.count({
index: CONNECTORS_INDEX,
@ -65,7 +70,7 @@ export const fetchSyncJobsStats = async (
const response = {
connected: connectedResponse.count,
errors: errorResponse.count,
idle: idleJobsCountResponse.count,
idle: idleJobsCountResponse?.count || 0,
in_progress: inProgressJobsCountResponse.count,
incomplete: incompleteResponse.count,
orphaned_jobs: orphanedJobsCountResponse.count,

View file

@ -126,54 +126,7 @@ export const getInProgressJobsCountQuery = (isCrawler?: boolean) => {
};
};
export const getIdleJobsCountQuery = (isCrawler?: boolean) => {
if (isCrawler === undefined) {
return {
bool: {
filter: [
{
term: {
status: SyncStatus.IN_PROGRESS,
},
},
{
range: {
last_seen: {
lt: moment().subtract(1, 'minute').toISOString(),
},
},
},
],
},
};
}
if (isCrawler) {
return {
bool: {
filter: [
{
term: {
status: SyncStatus.IN_PROGRESS,
},
},
{
term: {
'connector.service_type': CRAWLER_SERVICE_TYPE,
},
},
{
range: {
last_seen: {
lt: moment().subtract(1, 'minute').toISOString(),
},
},
},
],
},
};
}
export const getIdleJobsCountQuery = () => {
return {
bool: {
filter: [
@ -194,7 +147,7 @@ export const getIdleJobsCountQuery = (isCrawler?: boolean) => {
{
range: {
last_seen: {
lt: moment().subtract(1, 'minute').toISOString(),
lt: moment().subtract(5, 'minute').toISOString(),
},
},
},