CalculateKpiValues
Returns a list of KPI values for tests matching the specified filter.
- TypeScript
- Python
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);
})();
import os
import grpc
import yandexcloud
from yandex.cloud.loadtesting.api.v1.report.kpi_pb2 import Aggregation
from yandex.cloud.loadtesting.api.v1.report_service_pb2 import CalculateReportKpiValuesRequest
from yandex.cloud.loadtesting.api.v1.report.kpi_pb2 import Comparison
from yandex.cloud.loadtesting.api.v1.report.kpi_pb2 import Kpi
from yandex.cloud.loadtesting.api.v1.report.kpi_pb2 import KpiSelector
from yandex.cloud.loadtesting.api.v1.report.kpi_pb2 import KpiThreshold
from yandex.cloud.loadtesting.api.v1.common.quantiles_pb2 import QuantileType
from yandex.cloud.loadtesting.api.v1.report_service_pb2_grpc import ReportServiceStub
token = os.getenv("YC_OAUTH_TOKEN")
sdk = yandexcloud.SDK(token=token)
service = sdk.client(ReportServiceStub)
response = service.CalculateKpiValues(
CalculateReportKpiValuesRequest(
folder_id="folderId",
test_filter="testFilter",
# test_case = "testCase",
kpi=Kpi(
# selector = KpiSelector(
# response_time = KpiSelector.ResponseTime(
# quantile = QuantileType.QUANTILE_TYPE_50
# ),
# instances = KpiSelector.Instances(
# agg = Aggregation.AGGREGATION_MIN
# ),
# imbalance_rps = KpiSelector.ImbalanceRps(
# ),
# protocol_codes_absolute = KpiSelector.ProtocolCodesAbsolute(
# codes_patterns = ["codesPatterns"]
# ),
# protocol_codes_relative = KpiSelector.ProtocolCodesRelative(
# codes_patterns = ["codesPatterns"]
# ),
# network_codes_absolute = KpiSelector.NetworkCodesAbsolute(
# codes_patterns = ["codesPatterns"]
# ),
# network_codes_relative = KpiSelector.NetworkCodesRelative(
# codes_patterns = ["codesPatterns"]
# )
# ),
# threshold = KpiThreshold(
# value = 0,
# comparison = Comparison.COMPARISON_LT
# )
),
)
)
print(response)
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
: ResponseTimeResponse time cummulative quantile (percentile).
instances
: InstancesA number of instances throughout the test.
imbalanceRps
: ImbalanceRpsAn RPS at the moment the test has been auto-stopped.
protocolCodesAbsolute
: ProtocolCodesAbsoluteA total number of requests completed with certain protocol (HTTP, GRPC, etc.) codes.
protocolCodesRelative
: ProtocolCodesRelativeA percentage of requests completed with certain protocol (HTTP, GRPC, etc.) codes.
networkCodesAbsolute
: NetworkCodesAbsoluteA total number of requests completed with certain network codes.
networkCodesRelative
: NetworkCodesRelativeA 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'