Skip to content

Commit

Permalink
feat: support environment filtering (#482)
Browse files Browse the repository at this point in the history
<img width="221" alt="Screenshot 2024-07-24 at 2 34 07 PM" src="https://github.com/user-attachments/assets/2a4f9113-c567-4ce8-9992-6c11645c2126">
  • Loading branch information
wrn14897 authored Jul 25, 2024
1 parent 41eff91 commit 3b5ec64
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/rich-games-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@hyperdx/api': minor
'@hyperdx/app': minor
---

feat: copy "deployment.environment" resource attribute to the top level (span)
6 changes: 6 additions & 0 deletions .changeset/twelve-berries-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@hyperdx/api': patch
'@hyperdx/app': patch
---

feat: support environment filtering
5 changes: 5 additions & 0 deletions docker/ingestor/core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,11 @@ if is_object(.r) {
.b."k8s.deployment.name" = .b.process.tag."k8s.deployment.name"
}
# copy common resource attributes to the top level
if is_nullish(.b."deployment.environment") && !is_nullish(.b.process.tag."deployment.environment") {
.b."deployment.environment" = .b.process.tag."deployment.environment"
}
if (.b."span.kind" == "server") {
if (exists(.b."http.status_code") && exists(.b."http.method") && exists(.b."http.route")) {
.b._hdx_body = join([
Expand Down
7 changes: 6 additions & 1 deletion packages/api/src/routers/api/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ router.get('/services', async (req, res, next) => {
return res.sendStatus(403);
}

const FIELDS = ['k8s.namespace.name', 'k8s.pod.name', 'k8s.pod.uid'];
const FIELDS = [
'deployment.environment',
'k8s.namespace.name',
'k8s.pod.name',
'k8s.pod.uid',
];
const nowInMs = Date.now();
const startTime = nowInMs - ms('5d');
const endTime = nowInMs;
Expand Down
25 changes: 25 additions & 0 deletions packages/app/src/SearchPage.components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,19 @@ export const SearchPageFilters = ({
}));
}, [services]);

const environmentsOptions = React.useMemo(() => {
const allAttrs = Object.values(services?.data ?? {});
const envs = new Set<string>();
for (const attrs of allAttrs) {
for (const attr of attrs) {
if (attr['deployment.environment']) {
envs.add(attr['deployment.environment']);
}
}
}
return Array.from(envs).map(env => ({ value: env, label: env }));
}, [services]);

const { setFilterValue, filters, clearFilter } = useSearchPageFilterState({
searchQuery,
onSearchQueryChange,
Expand Down Expand Up @@ -331,6 +344,18 @@ export const SearchPageFilters = ({
onClearClick={() => clearFilter('service')}
onOnlyClick={value => setFilterValue('service', value, true)}
/>

<FilterGroup
name="Environment"
options={environmentsOptions}
optionsLoading={isServicesLoading}
selectedValues={filters['deployment.environment']}
onChange={value => setFilterValue('deployment.environment', value)}
onClearClick={() => clearFilter('deployment.environment')}
onOnlyClick={value =>
setFilterValue('deployment.environment', value, true)
}
/>
</Stack>
</ScrollArea>
</div>
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type ServicesResponse = {
data: Record<
string,
Array<{
'deployment.environment'?: string;
'k8s.namespace.name'?: string;
'k8s.pod.name'?: string;
'k8s.pod.uid'?: string;
Expand Down

0 comments on commit 3b5ec64

Please sign in to comment.