Skip to main content

CalculateKpiValues

Returns a list of KPI values for tests matching the specified filter.

import { cloudApi, serviceClients, Session } from "@yandex-cloud/nodejs-sdk";

const Aggregation = cloudApi.loadtesting.api_report_kpi.Aggregation;
const CalculateReportKpiValuesRequest =
cloudApi.loadtesting.api_report_service.CalculateReportKpiValuesRequest;
const Comparison = cloudApi.loadtesting.api_report_kpi.Comparison;
const QuantileType = cloudApi.loadtesting.api_common_quantiles.QuantileType;

(async () => {
const authToken = process.env["YC_OAUTH_TOKEN"];
const session = new Session({ oauthToken: authToken });
const client = session.client(serviceClients.ReportServiceClient);

const result = await client.calculateKpiValues(
CalculateReportKpiValuesRequest.fromPartial({
folderId: "folderId",
testFilter: "testFilter",
// testCase: "testCase",
kpi: {
// selector: {
// responseTime: {
// quantile: QuantileType.QUANTILE_TYPE_50
// },
// instances: {
// agg: Aggregation.AGGREGATION_MIN
// },
// imbalanceRps: {
// },
// protocolCodesAbsolute: {
// codesPatterns: ["codesPatterns"]
// },
// protocolCodesRelative: {
// codesPatterns: ["codesPatterns"]
// },
// networkCodesAbsolute: {
// codesPatterns: ["codesPatterns"]
// },
// networkCodesRelative: {
// codesPatterns: ["codesPatterns"]
// }
// },
// threshold: {
// value: 0,
// comparison: Comparison.COMPARISON_LT
// }
},
})
);
console.log(result);
})();

CalculateReportKpiValuesRequest

folderId : string

ID of the folder containing tests.

testFilter : string

Test filter selector to calculate KPI values for.

testCase : string

Test case to calculate KPI values for.

If not specified, KPI values will be calculated for 'overall' case.

kpi : report.Kpi

KPI to be calculated.

Kpi

KPI (Key Performance Indicator) represents some integral indicator measured during test.

selector : KpiSelector

Kind of KPI.

threshold : KpiThreshold

A condition that should be specified.

KpiSelector

KPI selector.

ResponseTime

Response time.

quantile : common.QuantileType

Cummulative quantile (percentile).

Instances

Aggregated number of instances.

agg : Aggregation

Aggregation function.

ImbalanceRps

Imbalance RPS.

ProtocolCodesAbsolute
codesPatterns : string

Protocol (HTTP, GRPC) code patterns to match.

All successful HTTP responses: '2xx', '3xx'. All failed HTTP responses: ['0', '4xx', '5xx'][2].

ProtocolCodesRelative
codesPatterns : string

Protocol (HTTP, GRPC) code patterns to match.

All successful HTTP responses: '2xx', '3xx'. All failed HTTP responses: ['0', '4xx', '5xx'][4].

NetworkCodesAbsolute
codesPatterns : string

Network code patterns to match.

All successful network responses: '0'. All failed network responses: 'xx', 'xxx'.

NetworkCodesRelative
codesPatterns : string

Network code patterns to match.

All successful network responses: '0'. All failed network responses: 'xx', 'xxx'.

One of kind

  • responseTime : ResponseTime

    Response time cummulative quantile (percentile).

  • instances : Instances

    A number of instances throughout the test.

  • imbalanceRps : ImbalanceRps

    An RPS at the moment the test has been auto-stopped.

  • protocolCodesAbsolute : ProtocolCodesAbsolute

    A total number of requests completed with certain protocol (HTTP, GRPC, etc.) codes.

  • protocolCodesRelative : ProtocolCodesRelative

    A percentage of requests completed with certain protocol (HTTP, GRPC, etc.) codes.

  • networkCodesAbsolute : NetworkCodesAbsolute

    A total number of requests completed with certain network codes.

  • networkCodesRelative : NetworkCodesRelative

    A percentage of requests completed with certain network codes.

KpiThreshold

KPI threshold represents a condition that an actual value of test's KPI should satisfy.

value : double

Value for comparison with an actual KPI value.

comparison : Comparison

Comparison operator for comparing actual with the threshold value.

Rule: actual (</<=/>/>=) reference

ResponseTime

Response time.

quantile : common.QuantileType

Cummulative quantile (percentile).

Instances

Aggregated number of instances.

agg : Aggregation

Aggregation function.

ImbalanceRps

Imbalance RPS.

ProtocolCodesAbsolute

codesPatterns : string

Protocol (HTTP, GRPC) code patterns to match.

All successful HTTP responses: '2xx', '3xx'. All failed HTTP responses: ['0', '4xx', '5xx'][10].

ProtocolCodesRelative

codesPatterns : string

Protocol (HTTP, GRPC) code patterns to match.

All successful HTTP responses: '2xx', '3xx'. All failed HTTP responses: ['0', '4xx', '5xx'][12].

NetworkCodesAbsolute

codesPatterns : string

Network code patterns to match.

All successful network responses: '0'. All failed network responses: 'xx', 'xxx'.

NetworkCodesRelative

codesPatterns : string

Network code patterns to match.

All successful network responses: '0'. All failed network responses: 'xx', 'xxx'.

CalculateReportKpiValuesResponse

folderId : string

ID of the folder.

values : report.KpiValue

Actual KPI values.

KpiValue

An actual value of test's KPI.

testId : string

ID of a test.

value : double

Value of KPI.

isOk : bool

A flag indicating whether the value satisfies KPI threshold condition.


[2]: #protocolcodesrelative'0', '4xx', '5xx'

[4]: #protocolcodesrelative'0', '4xx', '5xx'

[10]: #protocolcodesrelative'0', '4xx', '5xx'

[12]: #protocolcodesrelative'0', '4xx', '5xx'