added env
test-org/trust-module-backend/pipeline/pr-rc This commit looks good
Details
test-org/trust-module-backend/pipeline/pr-rc This commit looks good
Details
parent
4074d45384
commit
57cf65b9a6
3
.env
3
.env
|
|
@ -24,3 +24,6 @@
|
||||||
# COOKIE_SECURE=false
|
# COOKIE_SECURE=false
|
||||||
# COOKIE_SAME_SITE=lax
|
# COOKIE_SAME_SITE=lax
|
||||||
|
|
||||||
|
# Для меню
|
||||||
|
#RANGES_API_URL=http://192.168.2.39:9999
|
||||||
|
#RANGES_API_ENDPOINT=/api/ranges/9999
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,27 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { HttpService } from '@nestjs/axios';
|
import { HttpService } from '@nestjs/axios';
|
||||||
import { firstValueFrom } from 'rxjs';
|
import { firstValueFrom } from 'rxjs';
|
||||||
|
import { ConfigService } from '@nestjs/config';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RangeService {
|
export class RangeService {
|
||||||
constructor(private readonly httpService: HttpService) { }
|
private readonly rangesApiUrl: string;
|
||||||
|
private readonly rangesApiEndpoint: string;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly httpService: HttpService,
|
||||||
|
private readonly configService: ConfigService
|
||||||
|
) {
|
||||||
|
this.rangesApiUrl = this.configService.get<string>('RANGES_API_URL', 'localhost:3000');
|
||||||
|
this.rangesApiEndpoint = this.configService.get<string>('RANGES_API_ENDPOINT', 'localhost:3000');
|
||||||
|
}
|
||||||
|
|
||||||
async getRanges(): Promise<Record<string, Array<{ min: number; max: number; status: number }>>> {
|
async getRanges(): Promise<Record<string, Array<{ min: number; max: number; status: number }>>> {
|
||||||
try {
|
try {
|
||||||
const response = await firstValueFrom(
|
const response = await firstValueFrom(
|
||||||
this.httpService.request({
|
this.httpService.request({
|
||||||
method: 'OPTIONS',
|
method: 'OPTIONS',
|
||||||
url: 'http://192.168.2.39:9999/api/ranges/9999',
|
url: `${this.rangesApiUrl}${this.rangesApiEndpoint}`,
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json'
|
'Accept': 'application/json'
|
||||||
}
|
}
|
||||||
|
|
@ -55,7 +65,7 @@ export class RangeService {
|
||||||
async updateRanges(data: Array<{ name: string; ranges: { min: number; max: number; status: number }[] }>) {
|
async updateRanges(data: Array<{ name: string; ranges: { min: number; max: number; status: number }[] }>) {
|
||||||
try {
|
try {
|
||||||
const response = await firstValueFrom(
|
const response = await firstValueFrom(
|
||||||
this.httpService.post('http://192.168.2.39:9999/api/ranges/9999', data, {
|
this.httpService.post(`${this.rangesApiUrl}${this.rangesApiEndpoint}`, data, {
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
@ -65,6 +75,4 @@ export class RangeService {
|
||||||
throw new Error('Failed to update ranges');
|
throw new Error('Failed to update ranges');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +124,7 @@ export class PrometheusService {
|
||||||
async fetchMetricsRange(metric: string, start: number, end: number, step: number, filters: Record<string, string> = {}): Promise<PrometheusMetric[]> {
|
async fetchMetricsRange(metric: string, start: number, end: number, step: number, filters: Record<string, string> = {}): Promise<PrometheusMetric[]> {
|
||||||
const query = this.buildFilteredQuery(metric, {
|
const query = this.buildFilteredQuery(metric, {
|
||||||
...filters,
|
...filters,
|
||||||
instance: '192.168.2.34:9050' // Явно фильтруем по нужному instance
|
instance: '192.168.2.34:9050'
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
const response = await lastValueFrom(
|
const response = await lastValueFrom(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue