[Profiling] Adding Azure settings (#176386)

closes https://github.com/elastic/kibana/issues/176376

<img width="1638" alt="Screenshot 2024-02-07 at 10 52 49"
src="997fa6a0-0c73-4252-8fa9-7f2231494c95">

**We have to wait until the ES
[PR](https://github.com/elastic/elasticsearch/pull/105231) is merged to
e2e test it.**
This commit is contained in:
Cauê Marcondes 2024-02-13 14:43:21 +00:00 committed by GitHub
parent 708db13e6e
commit 4010b318d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 165 additions and 51 deletions

View file

@ -466,6 +466,27 @@ preview:[] Enables the Profiling view in Host details within Infrastructure.
[[observability-infrastructure-hosts-custom-dashboard]]`observability:enableInfrastructureHostsCustomDashboards`::
preview:[] Enables option to link custom dashboards in the Host Details view.
[[observability-profiling-per-vcpu-watt-x86]]`observability:profilingPervCPUWattX86`::
The average amortized per-core power consumption (based on 100% CPU utilization) for x86 architecture.
[[observability-profiling-per-vcpu-watt-arm64]]`observability:profilingPervCPUWattArm64`::
The average amortized per-core power consumption (based on 100% CPU utilization) for arm64 architecture.
[[observability-profiling-datacenter-PUE]]`observability:profilingDatacenterPUE`::
Data center power usage effectiveness (PUE) measures how efficiently a data center uses energy. Defaults to 1.7, the average on-premise data center PUE according to the https://ela.st/uptimeinstitute[Uptime Institute] survey.
[[observability-profiling-per-co2-per-kwh]]`observability:profilingCo2PerKWH`::
Carbon intensity measures how clean your data center electricity is. Specifically, it measures the average amount of CO2 emitted per kilowatt-hour (kWh) of electricity consumed in a particular region.
[[observability-profiling-aws-cost-discount-rate]]`observability:profilingAWSCostDiscountRate`::
If you're enrolled in the AWS Enterprise Discount Program (EDP), enter your discount rate to update the profiling cost calculation.
[[observability-profiling-azure-cost-discount-rate]]`observability:profilingAzureCostDiscountRate`::
If you have an Azure Enterprise Agreement with Microsoft, enter your discount rate to update the profiling cost calculation.
[[observability-profiling-cost-per-vcpu-per-hour]]`observability:profilingCostPervCPUPerHour`::
Default Hourly Cost per CPU Core for machines not on AWS or Azure.
[float]
[[kibana-reporting-settings]]
==== Reporting

View file

@ -632,6 +632,10 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
type: 'integer',
_meta: { description: 'Non-default value of setting.' },
},
'observability:profilingAzureCostDiscountRate': {
type: 'integer',
_meta: { description: 'Non-default value of setting.' },
},
'data_views:fields_excluded_data_tiers': {
type: 'keyword',
_meta: { description: 'Non-default value of setting.' },

View file

@ -166,6 +166,7 @@ export interface UsageStats {
'observability:profilingDatacenterPUE': number;
'observability:profilingCostPervCPUPerHour': number;
'observability:profilingAWSCostDiscountRate': number;
'observability:profilingAzureCostDiscountRate': number;
'data_views:fields_excluded_data_tiers': string;
'observability:apmEnableTransactionProfiling': boolean;
'devTools:enableDockedConsole': boolean;

View file

@ -10264,6 +10264,12 @@
"description": "Non-default value of setting."
}
},
"observability:profilingAzureCostDiscountRate": {
"type": "integer",
"_meta": {
"description": "Non-default value of setting."
}
},
"data_views:fields_excluded_data_tiers": {
"type": "keyword",
"_meta": {

View file

@ -51,6 +51,7 @@ export {
profilingPervCPUWattArm64,
profilingAWSCostDiscountRate,
profilingCostPervCPUPerHour,
profilingAzureCostDiscountRate,
apmEnableTransactionProfiling,
} from './ui_settings_keys';

View file

@ -39,4 +39,5 @@ export const profilingCo2PerKWH = 'observability:profilingCo2PerKWH';
export const profilingDatacenterPUE = 'observability:profilingDatacenterPUE';
export const profilingAWSCostDiscountRate = 'observability:profilingAWSCostDiscountRate';
export const profilingCostPervCPUPerHour = 'observability:profilingCostPervCPUPerHour';
export const profilingAzureCostDiscountRate = 'observability:profilingAzureCostDiscountRate';
export const apmEnableTransactionProfiling = 'observability:apmEnableTransactionProfiling';

View file

@ -38,6 +38,7 @@ import {
profilingPervCPUWattArm64,
profilingAWSCostDiscountRate,
profilingCostPervCPUPerHour,
profilingAzureCostDiscountRate,
enableInfrastructureProfilingIntegration,
apmEnableTransactionProfiling,
enableInfrastructureHostsCustomDashboards,
@ -527,7 +528,7 @@ export const uiSettings: Record<string, UiSettings> = {
name: i18n.translate('xpack.observability.profilingAWSCostDiscountRateUiSettingName', {
defaultMessage: 'AWS EDP discount rate (%)',
}),
value: 6,
value: '0',
schema: schema.number({ min: 0, max: 100 }),
requiresPageReload: true,
description: i18n.translate(
@ -538,6 +539,22 @@ export const uiSettings: Record<string, UiSettings> = {
}
),
},
[profilingAzureCostDiscountRate]: {
category: [observabilityFeatureId],
name: i18n.translate('xpack.observability.profilingAzureCostDiscountRateUiSettingName', {
defaultMessage: 'Azure discount rate (%)',
}),
value: '0',
schema: schema.number({ min: 0, max: 100 }),
requiresPageReload: true,
description: i18n.translate(
'xpack.observability.profilingAzureCostDiscountRateUiSettingDescription',
{
defaultMessage:
'If you have an Azure Enterprise Agreement with Microsoft, enter your discount rate to update the profiling cost calculation.',
}
),
},
[profilingCostPervCPUPerHour]: {
category: [observabilityFeatureId],
name: i18n.translate('xpack.observability.profilingCostPervCPUPerHourUiSettingName', {
@ -547,7 +564,7 @@ export const uiSettings: Record<string, UiSettings> = {
description: i18n.translate(
'xpack.observability.profilingCostPervCPUPerHourUiSettingNameDescription',
{
defaultMessage: `Default average cost per CPU core per hour (Non-AWS instances only)`,
defaultMessage: `Default Hourly Cost per CPU Core for machines not on AWS or Azure`,
}
),
schema: schema.number({ min: 0, max: 100 }),

View file

@ -39,6 +39,7 @@ describe('Settings page', () => {
cy.contains('Per vCPU Watts - arm64');
cy.contains('AWS EDP discount rate (%)');
cy.contains('Cost per vCPU per hour ($)');
cy.contains('Azure discount rate (%)');
cy.contains('Show error frames in the Universal Profiling views');
});

View file

@ -24,6 +24,7 @@ import {
profilingPervCPUWattX86,
profilingPervCPUWattArm64,
profilingAWSCostDiscountRate,
profilingAzureCostDiscountRate,
profilingCostPervCPUPerHour,
profilingShowErrorFrames,
} from '@kbn/observability-plugin/common';
@ -47,7 +48,11 @@ const co2Settings = [
profilingPervCPUWattX86,
profilingPervCPUWattArm64,
];
const costSettings = [profilingAWSCostDiscountRate, profilingCostPervCPUPerHour];
const costSettings = [
profilingAWSCostDiscountRate,
profilingAzureCostDiscountRate,
profilingCostPervCPUPerHour,
];
const miscSettings = [profilingShowErrorFrames];
export function Settings() {
@ -106,30 +111,57 @@ export function Settings() {
'The Universal Profiling host agent can detect if your machine is running on AWS, Azure, or Google Cloud Platform.',
}),
subtitle: (
<FormattedMessage
id="xpack.profiling.settings.co2.subtitle"
defaultMessage="For machines running on AWS, Universal Profiling applies the appropriate {regionalCarbonIntensityLink} for your instance's AWS region and the current AWS data center {pue}."
values={{
regionalCarbonIntensityLink: (
<EuiLink
data-test-subj="profilingSettingsLink"
href="https://ela.st/grid-datasheet"
target="_blank"
>
{i18n.translate('xpack.profiling.settings.co2.subtitle.link', {
defaultMessage: 'regional carbon intensity',
})}
</EuiLink>
),
pue: (
<strong>
{i18n.translate('xpack.profiling.settings.co2.subtitle.pue', {
defaultMessage: 'PUE',
})}
</strong>
),
}}
/>
<>
<FormattedMessage
id="xpack.profiling.settings.co2.aws.subtitle"
defaultMessage="For machines running on AWS, Universal Profiling applies the appropriate {regionalCarbonIntensityLink} for your instance's AWS region and the current AWS data center {pue}."
values={{
regionalCarbonIntensityLink: (
<EuiLink
data-test-subj="profilingSettingsLink"
href="https://ela.st/grid-datasheet"
target="_blank"
>
{i18n.translate('xpack.profiling.settings.co2.subtitle.link', {
defaultMessage: 'regional carbon intensity',
})}
</EuiLink>
),
pue: (
<strong>
{i18n.translate('xpack.profiling.settings.co2.subtitle.pue', {
defaultMessage: 'PUE',
})}
</strong>
),
}}
/>
<EuiSpacer size="xs" />
<FormattedMessage
id="xpack.profiling.settings.co2.azure.subtitle"
defaultMessage="For machines running on Azure, Universal Profiling applies the appropriate {regionalCarbonIntensityLink} for your instance's Azure region and the current Azure data center {pue}."
values={{
regionalCarbonIntensityLink: (
<EuiLink
data-test-subj="profilingSettingsLink"
href="https://ela.st/grid-datasheet"
target="_blank"
>
{i18n.translate('xpack.profiling.settings.co2.subtitle.link', {
defaultMessage: 'regional carbon intensity',
})}
</EuiLink>
),
pue: (
<strong>
{i18n.translate('xpack.profiling.settings.co2.subtitle.pue', {
defaultMessage: 'PUE',
})}
</strong>
),
}}
/>
</>
),
text: i18n.translate('xpack.profiling.settings.co2.text', {
defaultMessage:
@ -146,19 +178,30 @@ export function Settings() {
title: (
<FormattedMessage
id="xpack.profiling.settings.cost.title"
defaultMessage="Universal Profiling sets the cost for AWS configurations using the {awsPriceList} for your EC2 instance type."
defaultMessage="Universal Profiling uses the cost for AWS EC2 instances and Azure VMs using the {awsPriceList} and {azurePriceList} respectively."
values={{
awsPriceList: (
<EuiLink
data-test-subj="profilingSettingsLink"
href="https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/Welcome.html#Welcome_AWS_Price_List_Service"
data-test-subj="profilingSettingsLinkAws"
href="https://ela.st/aws-price-list"
target="_blank"
>
{i18n.translate('xpack.profiling.settings.cost.subtitle.link', {
{i18n.translate('xpack.profiling.settings.cost.subtitle.link.aws', {
defaultMessage: 'AWS price list',
})}
</EuiLink>
),
azurePriceList: (
<EuiLink
data-test-subj="profilingSettingsLinkAzure"
href="https://ela.st/azure-price-list"
target="_blank"
>
{i18n.translate('xpack.profiling.settings.cost.subtitle.link.azure', {
defaultMessage: 'Azure price list',
})}
</EuiLink>
),
}}
/>
),

View file

@ -19,7 +19,7 @@ export interface ProfilingESClient {
operationName: string,
searchRequest: TSearchRequest
): Promise<InferSearchResponseOf<TDocument, TSearchRequest>>;
profilingStacktraces({}: {
profilingStacktraces(params: {
query: QueryDslQueryContainer;
sampleSize: number;
durationSeconds: number;
@ -29,12 +29,13 @@ export interface ProfilingESClient {
pervCPUWattArm64?: number;
awsCostDiscountRate?: number;
costPervCPUPerHour?: number;
azureCostDiscountRate?: number;
indices?: string[];
stacktraceIdsField?: string;
}): Promise<StackTraceResponse>;
profilingStatus(params?: { waitForResourcesCreated?: boolean }): Promise<ProfilingStatusResponse>;
getEsClient(): ElasticsearchClient;
profilingFlamegraph({}: {
profilingFlamegraph(params: {
query: QueryDslQueryContainer;
sampleSize: number;
durationSeconds: number;
@ -43,6 +44,7 @@ export interface ProfilingESClient {
pervCPUWattX86?: number;
pervCPUWattArm64?: number;
awsCostDiscountRate?: number;
azureCostDiscountRate?: number;
costPervCPUPerHour?: number;
indices?: string[];
stacktraceIdsField?: string;

View file

@ -13,6 +13,7 @@ import {
profilingDatacenterPUE,
profilingPervCPUWattArm64,
profilingPervCPUWattX86,
profilingAzureCostDiscountRate,
} from '@kbn/observability-plugin/common';
import { percentToFactor } from '../../utils/percent_to_factor';
import { RegisterServicesParams } from '../register_services';
@ -44,6 +45,7 @@ export function createFetchFlamechart({ createProfilingEsClient }: RegisterServi
pervCPUWattArm64,
awsCostDiscountRate,
costPervCPUPerHour,
azureCostDiscountRate,
] = await Promise.all([
core.uiSettings.client.get<number>(profilingCo2PerKWH),
core.uiSettings.client.get<number>(profilingDatacenterPUE),
@ -51,6 +53,7 @@ export function createFetchFlamechart({ createProfilingEsClient }: RegisterServi
core.uiSettings.client.get<number>(profilingPervCPUWattArm64),
core.uiSettings.client.get<number>(profilingAWSCostDiscountRate),
core.uiSettings.client.get<number>(profilingCostPervCPUPerHour),
core.uiSettings.client.get<number>(profilingAzureCostDiscountRate),
]);
const profilingEsClient = createProfilingEsClient({ esClient });
@ -65,6 +68,7 @@ export function createFetchFlamechart({ createProfilingEsClient }: RegisterServi
pervCPUWattArm64,
awsCostDiscountRate: percentToFactor(awsCostDiscountRate),
costPervCPUPerHour,
azureCostDiscountRate: percentToFactor(azureCostDiscountRate),
indices,
stacktraceIdsField,
});

View file

@ -11,6 +11,7 @@ import {
profilingDatacenterPUE,
profilingPervCPUWattArm64,
profilingPervCPUWattX86,
profilingAzureCostDiscountRate,
profilingShowErrorFrames,
} from '@kbn/observability-plugin/common';
import { CoreRequestHandlerContext, ElasticsearchClient } from '@kbn/core/server';
@ -52,6 +53,7 @@ export function createFetchFunctions({ createProfilingEsClient }: RegisterServic
pervCPUWattArm64,
awsCostDiscountRate,
costPervCPUPerHour,
azureCostDiscountRate,
showErrorFrames,
] = await Promise.all([
core.uiSettings.client.get<number>(profilingCo2PerKWH),
@ -60,6 +62,7 @@ export function createFetchFunctions({ createProfilingEsClient }: RegisterServic
core.uiSettings.client.get<number>(profilingPervCPUWattArm64),
core.uiSettings.client.get<number>(profilingAWSCostDiscountRate),
core.uiSettings.client.get<number>(profilingCostPervCPUPerHour),
core.uiSettings.client.get<number>(profilingAzureCostDiscountRate),
core.uiSettings.client.get<boolean>(profilingShowErrorFrames),
]);
@ -76,6 +79,7 @@ export function createFetchFunctions({ createProfilingEsClient }: RegisterServic
pervCPUWattArm64,
awsCostDiscountRate: percentToFactor(awsCostDiscountRate),
costPervCPUPerHour,
azureCostDiscountRate: percentToFactor(azureCostDiscountRate),
indices,
stacktraceIdsField,
query,

View file

@ -9,6 +9,23 @@ import { decodeStackTraceResponse } from '@kbn/profiling-utils';
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { ProfilingESClient } from '../../../common/profiling_es_client';
interface Params {
client: ProfilingESClient;
sampleSize: number;
durationSeconds: number;
co2PerKWH: number;
datacenterPUE: number;
pervCPUWattX86: number;
pervCPUWattArm64: number;
awsCostDiscountRate: number;
costPervCPUPerHour: number;
azureCostDiscountRate: number;
showErrorFrames: boolean;
indices?: string[];
stacktraceIdsField?: string;
query: QueryDslQueryContainer;
}
export async function searchStackTraces({
client,
sampleSize,
@ -19,25 +36,12 @@ export async function searchStackTraces({
pervCPUWattArm64,
awsCostDiscountRate,
costPervCPUPerHour,
indices,
stacktraceIdsField,
query,
azureCostDiscountRate,
showErrorFrames,
}: {
client: ProfilingESClient;
sampleSize: number;
durationSeconds: number;
co2PerKWH: number;
datacenterPUE: number;
pervCPUWattX86: number;
pervCPUWattArm64: number;
awsCostDiscountRate: number;
costPervCPUPerHour: number;
indices?: string[];
stacktraceIdsField?: string;
query: QueryDslQueryContainer;
showErrorFrames: boolean;
}) {
indices,
query,
stacktraceIdsField,
}: Params) {
const response = await client.profilingStacktraces({
query,
sampleSize,
@ -48,6 +52,7 @@ export async function searchStackTraces({
pervCPUWattArm64,
awsCostDiscountRate,
costPervCPUPerHour,
azureCostDiscountRate,
indices,
stacktraceIdsField,
});

View file

@ -49,6 +49,7 @@ export function createProfilingEsClient({
costPervCPUPerHour,
pervCPUWattArm64,
pervCPUWattX86,
azureCostDiscountRate,
indices,
stacktraceIdsField,
}) {
@ -68,6 +69,7 @@ export function createProfilingEsClient({
datacenter_pue: datacenterPUE,
aws_cost_factor: awsCostDiscountRate,
cost_per_core_hour: costPervCPUPerHour,
azure_cost_factor: azureCostDiscountRate,
indices,
stacktrace_ids_field: stacktraceIdsField,
},
@ -114,6 +116,7 @@ export function createProfilingEsClient({
costPervCPUPerHour,
pervCPUWattArm64,
pervCPUWattX86,
azureCostDiscountRate,
indices,
stacktraceIdsField,
}) {
@ -134,6 +137,7 @@ export function createProfilingEsClient({
datacenter_pue: datacenterPUE,
aws_cost_factor: awsCostDiscountRate,
cost_per_core_hour: costPervCPUPerHour,
azure_cost_factor: azureCostDiscountRate,
indices,
stacktrace_ids_field: stacktraceIdsField,
},