common.go
common.go - Overview
-
Overview This file defines constants and functions related to infrastructure metrics, particularly for Kubernetes. It includes metric names to check, queries to determine if metrics are being sent, and functions to determine the appropriate table and aggregation level for top items queries.
-
Detailed Documentation
Constants
podMetricNamesToCheck
: A list of pod metric names to check.nodeMetricNamesToCheck
: A list of node metric names to check.clusterMetricNamesToCheck
: A list of cluster metric names to check.optionalPodMetricNamesToCheck
: A list of optional pod metric names to check (request/limit metrics).didSendPodMetricsQuery
: A query to check if any pod metrics have been sent. It uses string formatting with the database, table, and metric names.didSendNodeMetricsQuery
: A query to check if any node metrics have been sent. It uses string formatting with the database, table, and metric names.didSendClusterMetricsQuery
: A query to check if any cluster metrics have been sent. It uses string formatting with the database, table, and metric names.isSendingOptionalPodMetricsQuery
: A query to check if optional pod metrics are being sent. It uses string formatting with the database, table, and metric names.isSendingRequiredMetadataQuery
: A query to check if required metadata (cluster, node, namespace, deployment, statefulset, daemonset, cronjob, job) is being sent for pods. It uses string formatting with the database, table, and metric names.
Function: getParamsForTopItems
- Purpose: Determines the appropriate step interval, time series table name, and samples table name based on the time range provided for top items queries. The goal is to optimize query speed by using pre-aggregated data.
- Parameters:
start
(int64): The start timestamp in milliseconds.end
(int64): The end timestamp in milliseconds.
- Returns:
int64
: The step interval in seconds.string
: The time series table name.string
: The samples table name.
Function: getParamsForTopHosts
- Purpose: Determines the appropriate parameters for top hosts queries using
getParamsForTopItems
. - Parameters:
req
(model.HostListRequest): AHostListRequest
object containing the start and end times.
- Returns:
int64
: The step interval in seconds.string
: The time series table name.string
: The samples table name.
Function: getParamsForTopProcesses
- Purpose: Determines the appropriate parameters for top processes queries using
getParamsForTopItems
. - Parameters:
req
(model.ProcessListRequest): AProcessListRequest
object containing the start and end times.
- Returns:
int64
: The step interval in seconds.string
: The time series table name.string
: The samples table name.
Function: getParamsForTopPods
- Purpose: Determines the appropriate parameters for top pods queries using
getParamsForTopItems
. - Parameters:
req
(model.PodListRequest): APodListRequest
object containing the start and end times.
- Returns:
int64
: The step interval in seconds.string
: The time series table name.string
: The samples table name.
Function: getParamsForTopNodes
- Purpose: Determines the appropriate parameters for top nodes queries using
getParamsForTopItems
. - Parameters:
req
(model.NodeListRequest): ANodeListRequest
object containing the start and end times.
- Returns:
int64
: The step interval in seconds.string
: The time series table name.string
: The samples table name.
Function: getParamsForTopNamespaces
- Purpose: Determines the appropriate parameters for top namespaces queries using
getParamsForTopItems
. - Parameters:
req
(model.NamespaceListRequest): ANamespaceListRequest
object containing the start and end times.
- Returns:
int64
: The step interval in seconds.string
: The time series table name.string
: The samples table name.
Function: getParamsForTopClusters
- Purpose: Determines the appropriate parameters for top clusters queries using
getParamsForTopItems
. - Parameters:
req
(model.ClusterListRequest): AClusterListRequest
object containing the start and end times.
- Returns:
int64
: The step interval in seconds.string
: The time series table name.string
: The samples table name.
Function: getParamsForTopDeployments
- Purpose: Determines the appropriate parameters for top deployments queries using
getParamsForTopItems
. - Parameters:
req
(model.DeploymentListRequest): ADeploymentListRequest
object containing the start and end times.
- Returns:
int64
: The step interval in seconds.string
: The time series table name.string
: The samples table name.
Function: getParamsForTopDaemonSets
- Purpose: Determines the appropriate parameters for top daemon sets queries using
getParamsForTopItems
. - Parameters:
req
(model.DaemonSetListRequest): ADaemonSetListRequest
object containing the start and end times.
- Returns:
int64
: The step interval in seconds.string
: The time series table name.string
: The samples table name.
Function: getParamsForTopStatefulSets
- Purpose: Determines the appropriate parameters for top stateful sets queries using
getParamsForTopItems
. - Parameters:
req
(model.StatefulSetListRequest): AStatefulSetListRequest
object containing the start and end times.
- Returns:
int64
: The step interval in seconds.string
: The time series table name.string
: The samples table name.
Function: getParamsForTopJobs
- Purpose: Determines the appropriate parameters for top jobs queries using
getParamsForTopItems
. - Parameters:
req
(model.JobListRequest): AJobListRequest
object containing the start and end times.
- Returns:
int64
: The step interval in seconds.string
: The time series table name.string
: The samples table name.
Function: getParamsForTopVolumes
- Purpose: Determines the appropriate parameters for top volumes queries using
getParamsForTopItems
. - Parameters:
req
(model.VolumeListRequest): AVolumeListRequest
object containing the start and end times.
- Returns:
int64
: The step interval in seconds.string
: The time series table name.string
: The samples table name.
Function: localQueryToDistributedQuery
- Purpose: Replaces the local time series table name in a query with the distributed time series table name. This is done to query across all shards.
- Parameters:
query
(string): The query string.
- Returns:
string
: The modified query string with the table name replaced.
- Code Examples
// Example usage of getParamsForTopItems
const start = Date.now() - (2 * 60 * 60 * 1000); // 2 hours ago
const end = Date.now();
const [step, timeSeriesTable, samplesTable] = getParamsForTopItems(start, end);
console.log(`Step: ${step}, TimeSeriesTable: ${timeSeriesTable}, SamplesTable: ${samplesTable}`);
Include in Getting Started: NO