Skip to content

Commit

Permalink
Merge pull request #53 from polaris-slo-cloud/feature/composed-metric…
Browse files Browse the repository at this point in the history
…-interval

Allow configuring the computation interval of composed metric controllers
  • Loading branch information
tommazzo89 authored Apr 26, 2022
2 parents b4337c8 + bb97e4a commit 11d5c61
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Polaris SLO Cloud Changelog

## v0.3.1 (not yet released)
## v0.4.0 (not yet released)

### Features

* Allow configuring the computation interval of a composed metric controller through the `COMPOSED_METRIC_COMPUTATION_INTERVAL_MS` environment variable.

### Dependency Updates

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ spec:
value: '3000' # If this is changed, the containerPort above needs to be changed accordingly as well.
- name: PROMETHEUS_METRICS_ENDPOINT_PATH
value: /metrics
# Composed Metric computation interval in milliseconds.
# When changing this, you might also want to change the scrape interval in 3-service-monitor.yaml.
- name: COMPOSED_METRIC_COMPUTATION_INTERVAL_MS
value: '20000'
# Workaround for an issue with kubernetes-client when using IPv6 (https://github.com/kubernetes-client/javascript/issues/599)
- name: KUBERNETES_SERVICE_HOST
value: kubernetes.default.svc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
initPolarisLib as initCommonMappingsLib,
} from '@polaris-sloc/common-mappings';
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import { Logger } from '@polaris-sloc/core';
import { COMPOSED_METRIC_COMPUTATION_DEFAULT_INTERVAL_MS, Logger } from '@polaris-sloc/core';
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import { initCostEfficiencyMetrics } from '@polaris-sloc/cost-efficiency';
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
Expand Down Expand Up @@ -44,8 +44,11 @@ promMetricsCollectorManager.start({ path: metricsEndpointPath, port: metricsEndp

// Create a ComposedMetricsManager and watch the supported composed metric type kinds.
const manager = polarisRuntime.createComposedMetricsManager();
const intervalMsec = getEnvironmentVariable('COMPOSED_METRIC_COMPUTATION_INTERVAL_MS', convertToNumber) || COMPOSED_METRIC_COMPUTATION_DEFAULT_INTERVAL_MS
Logger.log(`Starting ComposedMetricsManager with a computation interval of ${intervalMsec} milliseconds.`);
manager
.startWatching({
evaluationIntervalMs: intervalMsec,
collectorFactories: [promMetricsCollectorManager],
kindsToWatch: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ spec:
value: '3000' # If this is changed, the containerPort above needs to be changed accordingly as well.
- name: PROMETHEUS_METRICS_ENDPOINT_PATH
value: /metrics
# Composed Metric computation interval in milliseconds.
# When changing this, you might also want to change the scrape interval in 3-service-monitor.yaml.
- name: COMPOSED_METRIC_COMPUTATION_INTERVAL_MS
value: '20000'
# Workaround for an issue with kubernetes-client when using IPv6 (https://github.com/kubernetes-client/javascript/issues/599)
- name: KUBERNETES_SERVICE_HOST
value: kubernetes.default.svc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { KubeConfig } from '@kubernetes/client-node';
import { CostEfficiencyMetric, CostEfficiencyMetricMapping, initPolarisLib as initCommonMappingsLib } from '@polaris-sloc/common-mappings';
import { Logger, convertToNumber, getEnvironmentVariable } from '@polaris-sloc/core';
import { COMPOSED_METRIC_COMPUTATION_DEFAULT_INTERVAL_MS, Logger, convertToNumber, getEnvironmentVariable } from '@polaris-sloc/core';
import { RestApiCostEfficiencyMetricSourceFactory, initCostEfficiencyMetrics } from '@polaris-sloc/cost-efficiency';
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import { initPolarisKubernetes } from '@polaris-sloc/kubernetes';
Expand Down Expand Up @@ -33,7 +33,10 @@ promMetricsCollectorManager.start({ path: metricsEndpointPath, port: metricsEndp

// Create a ComposedMetricsManager and watch the supported composed metric type kinds.
const manager = polarisRuntime.createComposedMetricsManager();
const intervalMsec = getEnvironmentVariable('COMPOSED_METRIC_COMPUTATION_INTERVAL_MS', convertToNumber) || COMPOSED_METRIC_COMPUTATION_DEFAULT_INTERVAL_MS
Logger.log(`Starting ComposedMetricsManager with a computation interval of ${intervalMsec} milliseconds.`);
manager.startWatching({
evaluationIntervalMs: intervalMsec,
collectorFactories: [ promMetricsCollectorManager ],
kindsToWatch: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ spec:
value: '3000' # If this is changed, the containerPort above needs to be changed accordingly as well.
- name: PROMETHEUS_METRICS_ENDPOINT_PATH
value: /metrics
# Composed Metric computation interval in milliseconds.
# When changing this, you might also want to change the scrape interval in 3-service-monitor.yaml.
- name: COMPOSED_METRIC_COMPUTATION_INTERVAL_MS
value: '20000'
# Workaround for an issue with kubernetes-client when using IPv6 (https://github.com/kubernetes-client/javascript/issues/599)
- name: KUBERNETES_SERVICE_HOST
value: kubernetes.default.svc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { KubeConfig } from '@kubernetes/client-node';
import { <%= compMetricType %>, <%= compMetricMapping %>, <%= initPolarisLibFn %> as initCompMetricsLib } from '<%= compMetricTypePkg %>';
import { Logger, convertToNumber, getEnvironmentVariable } from '@polaris-sloc/core';
import { COMPOSED_METRIC_COMPUTATION_DEFAULT_INTERVAL_MS, Logger, convertToNumber, getEnvironmentVariable } from '@polaris-sloc/core';
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import { initPolarisKubernetes } from '@polaris-sloc/kubernetes';
import { PrometheusComposedMetricsCollectorManager, initPrometheusQueryBackend } from '@polaris-sloc/prometheus';
Expand All @@ -27,7 +27,10 @@ promMetricsCollectorManager.start({ path: metricsEndpointPath, port: metricsEndp

// Create a ComposedMetricsManager and watch the supported composed metric type kinds.
const manager = polarisRuntime.createComposedMetricsManager();
const intervalMsec = getEnvironmentVariable('COMPOSED_METRIC_COMPUTATION_INTERVAL_MS', convertToNumber) || COMPOSED_METRIC_COMPUTATION_DEFAULT_INTERVAL_MS
Logger.log(`Starting ComposedMetricsManager with a computation interval of ${intervalMsec} milliseconds.`);
manager.startWatching({
evaluationIntervalMs: intervalMsec,
collectorFactories: [ promMetricsCollectorManager ],
kindsToWatch: [
{
Expand Down

0 comments on commit 11d5c61

Please sign in to comment.