Skip to content

Commit

Permalink
Merge pull request #77 from polaris-slo-cloud/feature/count-by-group
Browse files Browse the repository at this point in the history
countByGroup support in TimeInstantQuery
  • Loading branch information
tommazzo89 authored Nov 3, 2023
2 parents b6d38d8 + d74ff72 commit 6431009
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 26 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Polaris SLO Framework Changelog

## v0.7.0 (2023-11-03)

### Features

* Add `countByGroup()` to `TimeInstantQuery`.



## v0.6.3 (2023-09-01)

### Bugfixes
Expand Down
2 changes: 1 addition & 1 deletion ts/apps/polaris-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polaris-sloc/cli",
"version": "0.6.3",
"version": "0.7.0",
"license": "Apache-2.0",
"author": "Polaris SLO Framework Authors",
"private": false,
Expand Down
4 changes: 2 additions & 2 deletions ts/libs/common-mappings/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@polaris-sloc/common-mappings",
"version": "0.6.3",
"version": "0.7.0",
"license": "Apache-2.0",
"author": "Polaris SLO Framework Authors",
"private": false,
"type": "commonjs",
"peerDependencies": {
"@polaris-sloc/core": "~0.6.3",
"@polaris-sloc/core": "~0.7.0",
"tslib": "^2.6.2"
}
}
2 changes: 1 addition & 1 deletion ts/libs/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polaris-sloc/core",
"version": "0.6.3",
"version": "0.7.0",
"license": "Apache-2.0",
"author": "Polaris SLO Framework Authors",
"private": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {
BinaryOperationQueryContent,
BinaryOperationWithConstOperandQueryContent,
FilterOnValueQueryContent,
HistogramQuantileQueryContent,
QueryContentType,
createQueryContent,
HistogramQuantileQueryContent,
} from '../query-content';
import { TimeSeriesQueryBase } from './time-series-query.base';

Expand Down Expand Up @@ -142,6 +142,17 @@ export abstract class TimeInstantQueryBase<T> extends TimeSeriesQueryBase<TimeSe
return this.createTimeInstantQuery(queryContent);
}

countByGroup(groupingConfig?: LabelGroupingConfig): TimeInstantQuery<T> {
const queryContent = createQueryContent(
QueryContentType.AggregateByGroup,
{
aggregationType: 'count',
groupingConfig,
},
);
return this.createTimeInstantQuery(queryContent);
}

filterOnValue(predicate: ValueFilter): TimeInstantQuery<T> {
const queryContent: FilterOnValueQueryContent = {
contentType: QueryContentType.FilterOnValue,
Expand All @@ -154,8 +165,8 @@ export abstract class TimeInstantQueryBase<T> extends TimeSeriesQueryBase<TimeSe
const queryContent: HistogramQuantileQueryContent = {
contentType: QueryContentType.HistogramQuantile,
quantile,
functionName: 'histogramQuantile'
}
functionName: 'histogramQuantile',
};
return this.createTimeInstantQuery(queryContent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export interface FunctionQueryContent extends QueryContent {

}

export type AggregationType = 'sum' | 'min' | 'max' | 'avg'; // ToDo: extend
export type AggregationType = 'sum' | 'min' | 'max' | 'avg' | 'count'; // ToDo: extend

/**
* Describes a query that performs an aggregation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,24 @@ export interface TimeInstantQuery<T> extends ValueFilterableQuery<TimeSeriesInst
*/
maxByGroup(groupingConfig?: LabelGroupingConfig): TimeInstantQuery<number>;

/**
* Groups the `TimeSeries` using the specified `LabelGroupingConfig` and then
* counts the number of elements each group.
*
* @param groupingConfig The configuration used for grouping. Use the static methods of the `LabelGrouping` class
* to create this parameter. If no config is specified, no grouping is performed.
* @returns A `TimeInstantQuery` with one `TimeSeriesInstant` per group.
*/
countByGroup(groupingConfig?: LabelGroupingConfig): TimeInstantQuery<T>;

/**
* Calculates the `quantile` from a histgoram.
*
* @param quantile The quantile to calculate. Must be between 0 and 100.
* @returns A `TimeInstantQuery` with the quantile value from the histogram.
*/
histogramQuantile(quantile: number): TimeInstantQuery<T>
histogramQuantile(quantile: number): TimeInstantQuery<T>;

}

/**
Expand Down
4 changes: 2 additions & 2 deletions ts/libs/cost-efficiency/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@polaris-sloc/cost-efficiency",
"version": "0.6.3",
"version": "0.7.0",
"license": "Apache-2.0",
"author": "Polaris SLO Framework Authors",
"private": false,
"type": "commonjs",
"peerDependencies": {
"@polaris-sloc/core": "~0.6.3",
"@polaris-sloc/core": "~0.7.0",
"tslib": "^2.6.2"
}
}
4 changes: 2 additions & 2 deletions ts/libs/kubernetes/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polaris-sloc/kubernetes",
"version": "0.6.3",
"version": "0.7.0",
"license": "Apache-2.0",
"author": "Polaris SLO Framework Authors",
"private": false,
Expand All @@ -9,7 +9,7 @@
"@kubernetes/client-node": "^0.18.1"
},
"peerDependencies": {
"@polaris-sloc/core": "~0.6.3",
"@polaris-sloc/core": "~0.7.0",
"tslib": "^2.6.2"
},
"optionalDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions ts/libs/polaris-nx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polaris-sloc/polaris-nx",
"version": "0.6.3",
"version": "0.7.0",
"license": "Apache-2.0",
"author": "Polaris SLO Framework Authors",
"private": false,
Expand All @@ -14,9 +14,9 @@
"@nx/js": "16.0.0",
"@nx/node": "16.0.0",
"@nx/workspace": "16.0.0",
"@polaris-sloc/core": "~0.6.3",
"@polaris-sloc/kubernetes": "~0.6.3",
"@polaris-sloc/schema-gen": "~0.6.3",
"@polaris-sloc/core": "~0.7.0",
"@polaris-sloc/kubernetes": "~0.7.0",
"@polaris-sloc/schema-gen": "~0.7.0",
"axios": "1.3.6",
"grafana-dash-gen": "^3.2.1",
"nx": "*",
Expand Down
2 changes: 1 addition & 1 deletion ts/libs/polaris-nx/src/util/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const POLARIS_NPM_ORG = '@polaris-sloc';
* Defines the versions of packages added by the generators.
*/
export const VERSIONS = {
polaris: '0.6.3',
polaris: '0.7.0',
rxJs: '^6.6.7',
tsNode: '^10.9.1',
tsNodeConfigPaths: '^4.2.0',
Expand Down
4 changes: 2 additions & 2 deletions ts/libs/prometheus/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polaris-sloc/prometheus",
"version": "0.6.3",
"version": "0.7.0",
"license": "Apache-2.0",
"author": "Polaris SLO Framework Authors",
"private": false,
Expand All @@ -12,7 +12,7 @@
"safe-flat": "^2.0.2"
},
"peerDependencies": {
"@polaris-sloc/core": "~0.6.3",
"@polaris-sloc/core": "~0.7.0",
"tslib": "^2.6.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const AGGREGATIONS_MAP: Record<AggregationType, string> = {
min: 'min',
max: 'max',
avg: 'avg',
count: 'count',
};

/**
Expand All @@ -56,7 +57,7 @@ const BINARY_OPS_MAP: Record<BinaryOperator, string> = {
const FUNCTIONS_MAP: Record<DBFunctionName, string> = {
rate: 'rate',
averageOverTime: 'avg_over_time',
histogramQuantile: 'histogram_quantile'
histogramQuantile: 'histogram_quantile',
};

export class PrometheusNativeQueryBuilder extends NativeQueryBuilderBase {
Expand Down
4 changes: 2 additions & 2 deletions ts/libs/schema-gen/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polaris-sloc/schema-gen",
"version": "0.6.3",
"version": "0.7.0",
"license": "Apache-2.0",
"author": "Polaris SLO Framework Authors",
"private": false,
Expand All @@ -13,7 +13,7 @@
"ts-json-schema-generator": "1.0.0"
},
"peerDependencies": {
"@polaris-sloc/core": "~0.6.3",
"@polaris-sloc/core": "~0.7.0",
"rxjs": "^6.6.7",
"tslib": "^2.6.2"
}
Expand Down
4 changes: 2 additions & 2 deletions ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polaris-sloc",
"version": "0.6.3",
"version": "0.7.0",
"license": "Apache-2.0",
"scripts": {
"nx": "nx",
Expand Down

0 comments on commit 6431009

Please sign in to comment.