Merge branch 'feature' of http://git.enode/deployer3000/trust-module-backend into feature
commit
0afbcd7467
|
|
@ -8,4 +8,6 @@ RUN npm install
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
ENV NODE_ENV=development
|
||||||
|
|
||||||
CMD ["npm", "run", "start:dev"]
|
CMD ["npm", "run", "start:dev"]
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@ pipeline {
|
||||||
always {
|
always {
|
||||||
script {
|
script {
|
||||||
echo "Cleaning up workspace..."
|
echo "Cleaning up workspace..."
|
||||||
sh "rm -rf ${env.WORKSPACE}/package/ || true"
|
|
||||||
sh "rm -rf ${env.WORKSPACE}/rc/ || true"
|
sh "rm -rf ${env.WORKSPACE}/rc/ || true"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +55,7 @@ pipeline {
|
||||||
-u "${GITEA_USER}:${GITEA_PASS}" \
|
-u "${GITEA_USER}:${GITEA_PASS}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{"do":"merge"}' \
|
-d '{"do":"merge"}' \
|
||||||
http://git.entcor/api/v1/repos/DmitriyA/trust-module-backend/pulls/${prId}/merge
|
http://git.entcor/api/v1/repos/deployer3000/trust-module-backend/pulls/${prId}/merge
|
||||||
"""
|
"""
|
||||||
echo "PR ${prId} merged successfully into master!"
|
echo "PR ${prId} merged successfully into master!"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,10 @@ import { PrometheusMetric } from './prometheus-metric.interface';
|
||||||
export class PrometheusService {
|
export class PrometheusService {
|
||||||
private readonly prometheusUrl: string;
|
private readonly prometheusUrl: string;
|
||||||
|
|
||||||
constructor(
|
constructor(private readonly httpService: HttpService) { }
|
||||||
private readonly httpService: HttpService,
|
|
||||||
private readonly configService: ConfigService
|
//Получаем тип метрики
|
||||||
) {
|
|
||||||
this.prometheusUrl = this.configService.get<string>('PROMETHEUS_API', 'http://localhost:9090');
|
|
||||||
console.log('Prometheus API URL:', this.prometheusUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Получаем тип метрики
|
|
||||||
async fetchMetricType(metric: string): Promise<string | null> {
|
async fetchMetricType(metric: string): Promise<string | null> {
|
||||||
try {
|
try {
|
||||||
const response = await lastValueFrom(
|
const response = await lastValueFrom(
|
||||||
|
|
@ -33,24 +28,8 @@ export class PrometheusService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Получаем описание метрики
|
//Данные конкретной метрики, включая ее тип
|
||||||
async fetchMetricDescription(metric: string): Promise<string | undefined> {
|
|
||||||
try {
|
|
||||||
const response = await lastValueFrom(
|
|
||||||
this.httpService.get(`${this.prometheusUrl}/metadata`, {
|
|
||||||
params: { metric },
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
const metadata = response.data.data[metric];
|
|
||||||
return metadata?.length ? metadata[0].help : undefined;
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`Ошибка при получении описания метрики ${metric}:`, error);
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Получаем данные метрики (текущие значения)
|
|
||||||
async fetchMetrics(metric: string): Promise<PrometheusMetric[]> {
|
async fetchMetrics(metric: string): Promise<PrometheusMetric[]> {
|
||||||
const response = await lastValueFrom(
|
const response = await lastValueFrom(
|
||||||
this.httpService.get(`${this.prometheusUrl}/query`, {
|
this.httpService.get(`${this.prometheusUrl}/query`, {
|
||||||
|
|
@ -58,46 +37,18 @@ export class PrometheusService {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const metricType = await this.fetchMetricType(metric);
|
const metricType = await this.fetchMetricType(metric); // Получаем тип
|
||||||
const metricDescription = await this.fetchMetricDescription(metric);
|
|
||||||
|
|
||||||
return response.data.data.result.map((entry): PrometheusMetric => ({
|
return response.data.data.result.map((entry): PrometheusMetric => ({
|
||||||
...entry.metric,
|
...entry.metric,
|
||||||
timestamp: entry.value[0] * 1000,
|
timestamp: entry.value[0] * 1000, // Преобразуем в миллисекунды
|
||||||
value: parseFloat(entry.value[1]),
|
value: parseFloat(entry.value[1]), // Преобразуем в число
|
||||||
type: metricType || 'unknown',
|
type: metricType || 'unknown', // Добавляем тип метрики
|
||||||
description: metricDescription, // Добавляем описание
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Получаем данные метрики за интервал
|
//Получаем данные всех метрик
|
||||||
async fetchMetricsRange(metric: string, start: number, end: number, step: number): Promise<PrometheusMetric[]> {
|
|
||||||
const response = await lastValueFrom(
|
|
||||||
this.httpService.get(`${this.prometheusUrl}/query_range`, {
|
|
||||||
params: {
|
|
||||||
query: metric,
|
|
||||||
start,
|
|
||||||
end,
|
|
||||||
step,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
const metricType = await this.fetchMetricType(metric);
|
|
||||||
const metricDescription = await this.fetchMetricDescription(metric);
|
|
||||||
|
|
||||||
return response.data.data.result.flatMap((entry) =>
|
|
||||||
entry.values.map((value): PrometheusMetric => ({
|
|
||||||
...entry.metric,
|
|
||||||
timestamp: value[0] * 1000,
|
|
||||||
value: parseFloat(value[1]),
|
|
||||||
type: metricType || 'unknown',
|
|
||||||
description: metricDescription, // Добавляем описание
|
|
||||||
}))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Получаем список всех метрик
|
|
||||||
async fetchAllMetrics(): Promise<string[]> {
|
async fetchAllMetrics(): Promise<string[]> {
|
||||||
const response = await lastValueFrom(
|
const response = await lastValueFrom(
|
||||||
this.httpService.get(`${this.prometheusUrl}/label/__name__/values`)
|
this.httpService.get(`${this.prometheusUrl}/label/__name__/values`)
|
||||||
|
|
@ -105,7 +56,8 @@ export class PrometheusService {
|
||||||
return response.data.data;
|
return response.data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Получаем все метрики с их значениями
|
// Получаем список всех метрик
|
||||||
|
|
||||||
async fetchAllMetricsWithValues(): Promise<any[]> {
|
async fetchAllMetricsWithValues(): Promise<any[]> {
|
||||||
const metricNames = await this.fetchAllMetrics();
|
const metricNames = await this.fetchAllMetrics();
|
||||||
const promises = metricNames.map(async (metric) => {
|
const promises = metricNames.map(async (metric) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue