mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-10-15 14:31:30 +08:00

* feat: add documentation link for logs explorer quick filters * refactor: simplify QuickFilters component rendering logic * fix: properly implement the log fast filter empty state UI * fix: don't display empty state while loading quick filters * refactor: extract quick filter empty state into a separate component * refactor: render quick filters empty state based on source param * refactor: update QuickFilters source to use QuickFiltersSource.INFRA_MONITORING for consistency * fix: address review comments * refactor: fix the failing test by moving QuickFilters types to types.tsx * refactor: properly import use QuickFiltersSource --------- Co-authored-by: Vikrant Gupta <vikrant.thomso@gmail.com>
521 lines
12 KiB
TypeScript
521 lines
12 KiB
TypeScript
/* eslint-disable sonarjs/no-duplicate-string */
|
|
import {
|
|
FiltersType,
|
|
IQuickFiltersConfig,
|
|
} from 'components/QuickFilters/types';
|
|
import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
|
import { DataSource } from 'types/common/queryBuilder';
|
|
|
|
export const DEFAULT_PAGE_SIZE = 10;
|
|
|
|
export enum K8sCategory {
|
|
HOSTS = 'hosts',
|
|
PODS = 'pods',
|
|
NODES = 'nodes',
|
|
NAMESPACES = 'namespaces',
|
|
CLUSTERS = 'clusters',
|
|
DEPLOYMENTS = 'deployments',
|
|
STATEFULSETS = 'statefulsets',
|
|
DAEMONSETS = 'daemonsets',
|
|
CONTAINERS = 'containers',
|
|
JOBS = 'jobs',
|
|
VOLUMES = 'volumes',
|
|
}
|
|
|
|
export const K8sCategories = {
|
|
HOSTS: 'hosts',
|
|
PODS: 'pods',
|
|
NODES: 'nodes',
|
|
NAMESPACES: 'namespaces',
|
|
CLUSTERS: 'clusters',
|
|
DEPLOYMENTS: 'deployments',
|
|
STATEFULSETS: 'statefulsets',
|
|
DAEMONSETS: 'daemonsets',
|
|
CONTAINERS: 'containers',
|
|
JOBS: 'jobs',
|
|
VOLUMES: 'volumes',
|
|
};
|
|
|
|
export const K8sEntityToAggregateAttributeMapping = {
|
|
[K8sCategory.HOSTS]: 'system_cpu_load_average_15m',
|
|
[K8sCategory.PODS]: 'k8s_pod_cpu_utilization',
|
|
[K8sCategory.NODES]: 'k8s_node_cpu_utilization',
|
|
[K8sCategory.NAMESPACES]: 'k8s_pod_cpu_utilization',
|
|
[K8sCategory.CLUSTERS]: 'k8s_node_cpu_utilization',
|
|
[K8sCategory.DEPLOYMENTS]: 'k8s_pod_cpu_utilization',
|
|
[K8sCategory.STATEFULSETS]: 'k8s_pod_cpu_utilization',
|
|
[K8sCategory.DAEMONSETS]: 'k8s_pod_cpu_utilization',
|
|
[K8sCategory.CONTAINERS]: 'k8s_pod_cpu_utilization',
|
|
[K8sCategory.JOBS]: 'k8s_job_desired_successful_pods',
|
|
[K8sCategory.VOLUMES]: 'k8s_volume_capacity',
|
|
};
|
|
|
|
export const PodsQuickFiltersConfig: IQuickFiltersConfig[] = [
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Pod',
|
|
attributeKey: {
|
|
key: 'k8s_pod_name',
|
|
dataType: DataTypes.String,
|
|
type: 'tag',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
id: 'k8s_pod_name--string--tag--true',
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Namespace',
|
|
attributeKey: {
|
|
key: 'k8s_namespace_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: false,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Node',
|
|
attributeKey: {
|
|
key: 'k8s_node_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
id: 'k8s.node.name--string--resource--true',
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: false,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Cluster',
|
|
attributeKey: {
|
|
key: 'k8s_cluster_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: false,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Deployment',
|
|
attributeKey: {
|
|
key: 'k8s_deployment_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: false,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Statefulset',
|
|
attributeKey: {
|
|
key: 'k8s_statefulset_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: false,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'DaemonSet',
|
|
attributeKey: {
|
|
key: 'k8s_daemonset_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: false,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Job',
|
|
attributeKey: {
|
|
key: 'k8s_job_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: false,
|
|
},
|
|
];
|
|
|
|
export const NodesQuickFiltersConfig: IQuickFiltersConfig[] = [
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Node Name',
|
|
attributeKey: {
|
|
key: 'k8s_node_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Cluster Name',
|
|
attributeKey: {
|
|
key: 'k8s_cluster_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
];
|
|
|
|
export const NamespaceQuickFiltersConfig: IQuickFiltersConfig[] = [
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Namespace Name',
|
|
attributeKey: {
|
|
key: 'k8s_namespace_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Cluster Name',
|
|
attributeKey: {
|
|
key: 'k8s_cluster_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
];
|
|
|
|
export const ClustersQuickFiltersConfig: IQuickFiltersConfig[] = [
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Cluster Name',
|
|
attributeKey: {
|
|
key: 'k8s_cluster_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
];
|
|
|
|
export const ContainersQuickFiltersConfig: IQuickFiltersConfig[] = [
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Container',
|
|
attributeKey: {
|
|
key: 'k8s_container_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
defaultOpen: true,
|
|
},
|
|
];
|
|
|
|
export const VolumesQuickFiltersConfig: IQuickFiltersConfig[] = [
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'PVC Volume Claim Name',
|
|
attributeKey: {
|
|
key: 'k8s_persistentvolumeclaim_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_volume_capacity',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Namespace Name',
|
|
attributeKey: {
|
|
key: 'k8s_namespace_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_volume_capacity',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Cluster Name',
|
|
attributeKey: {
|
|
key: 'k8s_cluster_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_volume_capacity',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
];
|
|
|
|
export const DeploymentsQuickFiltersConfig: IQuickFiltersConfig[] = [
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Deployment Name',
|
|
attributeKey: {
|
|
key: 'k8s_deployment_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Namespace Name',
|
|
attributeKey: {
|
|
key: 'k8s_namespace_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Cluster Name',
|
|
attributeKey: {
|
|
key: 'k8s_cluster_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
];
|
|
|
|
export const StatefulsetsQuickFiltersConfig: IQuickFiltersConfig[] = [
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Statefulset Name',
|
|
attributeKey: {
|
|
key: 'k8s_statefulset_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Namespace Name',
|
|
attributeKey: {
|
|
key: 'k8s_namespace_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Cluster Name',
|
|
attributeKey: {
|
|
key: 'k8s_cluster_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
];
|
|
|
|
export const DaemonSetsQuickFiltersConfig: IQuickFiltersConfig[] = [
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'DaemonSet Name',
|
|
attributeKey: {
|
|
key: 'k8s_daemonset_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Namespace Name',
|
|
attributeKey: {
|
|
key: 'k8s_namespace_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Cluster Name',
|
|
attributeKey: {
|
|
key: 'k8s_cluster_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
];
|
|
|
|
export const JobsQuickFiltersConfig: IQuickFiltersConfig[] = [
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Job Name',
|
|
attributeKey: {
|
|
key: 'k8s_job_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Namespace Name',
|
|
attributeKey: {
|
|
key: 'k8s_namespace_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
{
|
|
type: FiltersType.CHECKBOX,
|
|
title: 'Cluster Name',
|
|
attributeKey: {
|
|
key: 'k8s_cluster_name',
|
|
dataType: DataTypes.String,
|
|
type: 'resource',
|
|
isColumn: false,
|
|
isJSON: false,
|
|
},
|
|
aggregateOperator: 'noop',
|
|
aggregateAttribute: 'k8s_pod_cpu_utilization',
|
|
dataSource: DataSource.METRICS,
|
|
defaultOpen: true,
|
|
},
|
|
];
|
|
|
|
export const getInvalidValueTooltipText = (
|
|
entity: K8sCategory,
|
|
attribute: string,
|
|
): string => `Some ${entity} do not have ${attribute}s.`;
|