-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Investigation app] add entities route and investigation Contextual Insight #194432
Merged
dominiqueclarke
merged 27 commits into
elastic:main
from
dominiqueclarke:feature/investigation-entities
Oct 4, 2024
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
27c0182
add entities route
dominiqueclarke 2d305e7
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 84a3817
Merge branch 'main' into feature/investigation-entities
dominiqueclarke dc8c47a
add initial contextual insight
dominiqueclarke be4dfb7
merge main
dominiqueclarke 16f926d
adjust entities es client
dominiqueclarke 72914b4
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine a67953d
add entity sources to the assistant prompt
dominiqueclarke f041ec1
Merge branch 'feature/investigation-entities' of github.com:dominique…
dominiqueclarke 503b7f8
adjust prompt
dominiqueclarke 552d79c
Merge branch 'main' of https://github.com/elastic/kibana into feature…
dominiqueclarke 1d65aec
Update x-pack/plugins/observability_solution/investigate_app/public/h…
dominiqueclarke 2907990
remove unnecessary async keyword
dominiqueclarke 3c542d4
Merge branch 'feature/investigation-entities' of github.com:dominique…
dominiqueclarke 53655e5
pass esClient to getEntities
dominiqueclarke 3fb9019
remove entity history references
dominiqueclarke 862e98f
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine ed126e4
adjust alert hook
dominiqueclarke 2d119de
adjust plugin definition
dominiqueclarke 56b2fb1
Merge branch 'feature/investigation-entities' of github.com:dominique…
dominiqueclarke 1932efe
remove imports from ai assistant
dominiqueclarke b70caeb
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine c24a620
adjust types
dominiqueclarke d9d211b
Merge branch 'feature/investigation-entities' of github.com:dominique…
dominiqueclarke 2a27f75
merge main
dominiqueclarke 4ab1a83
account for missing sources
dominiqueclarke f95017d
adjust types
dominiqueclarke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
packages/kbn-investigation-shared/src/rest_specs/entity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { z } from '@kbn/zod'; | ||
|
||
const metricsSchema = z.object({ | ||
failedTransactionRate: z.number().optional(), | ||
latency: z.number().optional(), | ||
throughput: z.number().optional(), | ||
logErrorRate: z.number().optional(), | ||
logRate: z.number().optional(), | ||
}); | ||
|
||
const entitySchema = z.object({ | ||
id: z.string(), | ||
definitionId: z.string(), | ||
definitionVersion: z.string(), | ||
displayName: z.string(), | ||
firstSeenTimestamp: z.string(), | ||
lastSeenTimestamp: z.string(), | ||
identityFields: z.array(z.string()), | ||
schemaVersion: z.string(), | ||
type: z.string(), | ||
metrics: metricsSchema, | ||
}); | ||
|
||
const entitySourceSchema = z.object({ | ||
dataStream: z.string().optional(), | ||
}); | ||
|
||
const entityWithSourceSchema = z.intersection( | ||
entitySchema, | ||
z.object({ | ||
sources: z.array(entitySourceSchema), | ||
}) | ||
); | ||
|
||
type EntityWithSource = z.output<typeof entityWithSourceSchema>; | ||
type EntitySource = z.output<typeof entitySourceSchema>; | ||
|
||
export { entitySchema, entityWithSourceSchema }; | ||
export type { EntityWithSource, EntitySource }; |
34 changes: 34 additions & 0 deletions
34
packages/kbn-investigation-shared/src/rest_specs/get_entities.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { z } from '@kbn/zod'; | ||
import { entityWithSourceSchema } from './entity'; | ||
|
||
const getEntitiesParamsSchema = z | ||
.object({ | ||
query: z | ||
.object({ | ||
'service.name': z.string(), | ||
'service.environment': z.string(), | ||
'host.name': z.string(), | ||
'container.id': z.string(), | ||
}) | ||
.partial(), | ||
}) | ||
.partial(); | ||
|
||
const getEntitiesResponseSchema = z.object({ | ||
entities: z.array(entityWithSourceSchema), | ||
}); | ||
|
||
type GetEntitiesParams = z.infer<typeof getEntitiesParamsSchema.shape.query>; | ||
type GetEntitiesResponse = z.output<typeof getEntitiesResponseSchema>; | ||
|
||
export { getEntitiesParamsSchema, getEntitiesResponseSchema }; | ||
export type { GetEntitiesParams, GetEntitiesResponse }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
x-pack/plugins/observability_solution/investigate_app/public/hooks/use_fetch_entities.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { useQuery } from '@tanstack/react-query'; | ||
import { GetEntitiesResponse } from '@kbn/investigation-shared'; | ||
import { useKibana } from './use_kibana'; | ||
import { investigationKeys } from './query_key_factory'; | ||
|
||
export interface EntityParams { | ||
investigationId: string; | ||
serviceName?: string; | ||
serviceEnvironment?: string; | ||
hostName?: string; | ||
containerId?: string; | ||
} | ||
|
||
export function useFetchEntities({ | ||
investigationId, | ||
serviceName, | ||
serviceEnvironment, | ||
hostName, | ||
containerId, | ||
}: EntityParams) { | ||
const { | ||
core: { http }, | ||
} = useKibana(); | ||
|
||
const { isInitialLoading, isLoading, isError, isSuccess, isRefetching, data } = useQuery({ | ||
queryKey: investigationKeys.entities({ | ||
investigationId, | ||
serviceName, | ||
serviceEnvironment, | ||
hostName, | ||
containerId, | ||
}), | ||
queryFn: async ({ signal }) => { | ||
return await http.get<GetEntitiesResponse>('/api/observability/investigation/entities', { | ||
query: { | ||
'service.name': serviceName, | ||
'service.environment': serviceEnvironment, | ||
'host.name': hostName, | ||
'container.id': containerId, | ||
}, | ||
version: '2023-10-31', | ||
signal, | ||
}); | ||
}, | ||
refetchOnWindowFocus: false, | ||
onError: (error: Error) => { | ||
// ignore error | ||
}, | ||
enabled: Boolean(investigationId && (serviceName || hostName || containerId)), | ||
}); | ||
|
||
return { | ||
data, | ||
isInitialLoading, | ||
isLoading, | ||
isRefetching, | ||
isSuccess, | ||
isError, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already in the requiredPlugins