Skip to content

Commit

Permalink
Added sampling information in frontend config
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierCazade committed Feb 10, 2023
1 parent 450b797 commit 49c0024
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/sample-frontend-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ quickFilters:
dst_kind: 'Service'
alertNamespaces:
- netobserv
sampling: 50
1 change: 1 addition & 0 deletions pkg/handler/frontend-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type frontendConfig struct {
} `yaml:"portNaming,omitempty" json:"portNaming"`
QuickFilters []QuickFilter `yaml:"quickFilters" json:"quickFilters"`
AlertNamespaces []string `yaml:"alertNamespaces" json:"alertNamespaces"`
Sampling int `yaml:"sampling" json:"sampling"`
}

func readConfigFile(filename string) (*frontendConfig, error) {
Expand Down
2 changes: 2 additions & 0 deletions web/locales/en/plugin__netobserv-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@
"Filtered top-k byte rate / filtered total byte rate": "Filtered top-k byte rate / filtered total byte rate",
"Filtered byte rate": "Filtered byte rate",
"Filtered sum of top-k packets / filtered total packets": "Filtered sum of top-k packets / filtered total packets",
"Configuration": "Configuration",
"Sampling": "Sampling",
"Cardinality": "Cardinality",
"(top {{count}} metrics)": "(top {{count}} metrics)",
"(top {{count}} metrics)_plural": "(top {{count}} metrics)",
Expand Down
3 changes: 2 additions & 1 deletion web/src/api/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ export const getConfig = (): Promise<Config> => {
: defaultConfig.portNaming.portNames
},
quickFilters: r.data.quickFilters,
alertNamespaces: r.data.alertNamespaces
alertNamespaces: r.data.alertNamespaces,
sampling: r.data.sampling
};
});
};
Expand Down
7 changes: 6 additions & 1 deletion web/src/components/query-summary/summary-panel.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@
flex-direction: column !important;
}

.summary-config-item {
padding-left: 15px;
flex-direction: column !important;
}

#cardinality-accordion {
display: flex;
flex-direction: column;
gap: 0;
}
}
12 changes: 12 additions & 0 deletions web/src/components/query-summary/summary-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { Stats, TopologyMetrics } from '../../api/loki';
import './summary-panel.css';
import { MetricType } from '../../model/flow-query';
import { MetricsQuerySummaryContent } from './metrics-query-summary';
import { config } from '../../utils/config';

type TypeCardinality = {
type: string;
Expand Down Expand Up @@ -119,6 +120,15 @@ export const SummaryPanelContent: React.FC<{
);
};

const configContent = () => {
return (
<TextContent className="summary-text-container">
<Text component={TextVariants.h3}>{`${t('Configuration')}`}</Text>
<Text className="summary-config-item">{`${t('Sampling')}: ${config.sampling}`}</Text>
</TextContent>
);
};

const cardinalityContent = () => {
//regroup all k8s objects per type + namespace
const namespaces: string[] = [];
Expand Down Expand Up @@ -317,6 +327,8 @@ export const SummaryPanelContent: React.FC<{

{cardinalityContent()}
{/*TODO: NETOBSERV-225 for extra stats on query*/}

{configContent()}
</>
);
};
Expand Down
4 changes: 3 additions & 1 deletion web/src/model/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type Config = {
};
quickFilters: RawQuickFilter[];
alertNamespaces: string[];
sampling: number;
};

export const defaultConfig: Config = {
Expand All @@ -15,5 +16,6 @@ export const defaultConfig: Config = {
portNames: new Map()
},
quickFilters: [],
alertNamespaces: ['netobserv']
alertNamespaces: ['netobserv'],
sampling: 50
};

0 comments on commit 49c0024

Please sign in to comment.