mirror of
https://github.com/Infisical/infisical.git
synced 2026-01-07 22:53:55 -05:00
misc: added support for more config options
This commit is contained in:
@@ -68,5 +68,10 @@ CAPTCHA_SECRET=
|
|||||||
|
|
||||||
NEXT_PUBLIC_CAPTCHA_SITE_KEY=
|
NEXT_PUBLIC_CAPTCHA_SITE_KEY=
|
||||||
|
|
||||||
OTEL_COLLECTOR_OTLP_URL=
|
|
||||||
OTEL_TELEMETRY_COLLECTION_ENABLED=
|
OTEL_TELEMETRY_COLLECTION_ENABLED=
|
||||||
|
OTEL_EXPORT_TYPE=
|
||||||
|
OTEL_EXPORT_OTLP_ENDPOINT=
|
||||||
|
OTEL_OTLP_PUSH_INTERVAL=
|
||||||
|
|
||||||
|
OTEL_COLLECTOR_BASIC_AUTH_USERNAME=
|
||||||
|
OTEL_COLLECTOR_BASIC_AUTH_PASSWORD=
|
||||||
|
|||||||
@@ -125,7 +125,11 @@ const envSchema = z
|
|||||||
MAINTENANCE_MODE: zodStrBool.default("false"),
|
MAINTENANCE_MODE: zodStrBool.default("false"),
|
||||||
CAPTCHA_SECRET: zpStr(z.string().optional()),
|
CAPTCHA_SECRET: zpStr(z.string().optional()),
|
||||||
OTEL_TELEMETRY_COLLECTION_ENABLED: zodStrBool.default("false"),
|
OTEL_TELEMETRY_COLLECTION_ENABLED: zodStrBool.default("false"),
|
||||||
OTEL_COLLECTOR_OTLP_URL: zpStr(z.string().optional())
|
OTEL_EXPORT_OTLP_ENDPOINT: zpStr(z.string().optional()),
|
||||||
|
OTEL_OTLP_PUSH_INTERVAL: z.coerce.number().default(30000),
|
||||||
|
OTEL_COLLECTOR_BASIC_AUTH_USERNAME: zpStr(z.string().optional()),
|
||||||
|
OTEL_COLLECTOR_BASIC_AUTH_PASSWORD: zpStr(z.string().optional()),
|
||||||
|
OTEL_EXPORT_TYPE: z.enum(["prometheus", "otlp"]).optional()
|
||||||
})
|
})
|
||||||
.transform((data) => ({
|
.transform((data) => ({
|
||||||
...data,
|
...data,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import opentelemetry from "@opentelemetry/api";
|
import opentelemetry, { diag, DiagConsoleLogger, DiagLogLevel } from "@opentelemetry/api";
|
||||||
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
|
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
|
||||||
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-proto";
|
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-proto";
|
||||||
import { PrometheusExporter } from "@opentelemetry/exporter-prometheus";
|
import { PrometheusExporter } from "@opentelemetry/exporter-prometheus";
|
||||||
@@ -7,7 +7,21 @@ import { Resource } from "@opentelemetry/resources";
|
|||||||
import { AggregationTemporality, MeterProvider, PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
|
import { AggregationTemporality, MeterProvider, PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
|
||||||
import { SEMRESATTRS_SERVICE_NAME, SEMRESATTRS_SERVICE_VERSION } from "@opentelemetry/semantic-conventions";
|
import { SEMRESATTRS_SERVICE_NAME, SEMRESATTRS_SERVICE_VERSION } from "@opentelemetry/semantic-conventions";
|
||||||
|
|
||||||
export const initTelemetry = async ({ otlpURL }: { otlpURL?: string }) => {
|
export const initTelemetryInstrumentation = async ({
|
||||||
|
exportType,
|
||||||
|
otlpURL,
|
||||||
|
otlpUser,
|
||||||
|
otlpPassword,
|
||||||
|
otlpPushInterval
|
||||||
|
}: {
|
||||||
|
exportType?: string;
|
||||||
|
otlpURL?: string;
|
||||||
|
otlpUser?: string;
|
||||||
|
otlpPassword?: string;
|
||||||
|
otlpPushInterval?: number;
|
||||||
|
}) => {
|
||||||
|
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
|
||||||
|
|
||||||
const resource = Resource.default().merge(
|
const resource = Resource.default().merge(
|
||||||
new Resource({
|
new Resource({
|
||||||
[SEMRESATTRS_SERVICE_NAME]: "infisical-server",
|
[SEMRESATTRS_SERVICE_NAME]: "infisical-server",
|
||||||
@@ -16,21 +30,30 @@ export const initTelemetry = async ({ otlpURL }: { otlpURL?: string }) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const metricReaders = [];
|
const metricReaders = [];
|
||||||
if (otlpURL) {
|
switch (exportType) {
|
||||||
|
case "prometheus": {
|
||||||
|
const promExporter = new PrometheusExporter();
|
||||||
|
metricReaders.push(promExporter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "otlp": {
|
||||||
const otlpExporter = new OTLPMetricExporter({
|
const otlpExporter = new OTLPMetricExporter({
|
||||||
url: `${otlpURL}/v1/metrics`,
|
url: `${otlpURL}/v1/metrics`,
|
||||||
|
headers: {
|
||||||
|
Authorization: `Basic ${btoa(`${otlpUser}:${otlpPassword}`)}`
|
||||||
|
},
|
||||||
temporalityPreference: AggregationTemporality.DELTA
|
temporalityPreference: AggregationTemporality.DELTA
|
||||||
});
|
});
|
||||||
|
|
||||||
metricReaders.push(
|
metricReaders.push(
|
||||||
new PeriodicExportingMetricReader({
|
new PeriodicExportingMetricReader({
|
||||||
exporter: otlpExporter,
|
exporter: otlpExporter,
|
||||||
exportIntervalMillis: 30000
|
exportIntervalMillis: otlpPushInterval
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
break;
|
||||||
const promExporter = new PrometheusExporter();
|
}
|
||||||
metricReaders.push(promExporter);
|
default:
|
||||||
|
throw new Error("Invalid OTEL export type");
|
||||||
}
|
}
|
||||||
|
|
||||||
const meterProvider = new MeterProvider({
|
const meterProvider = new MeterProvider({
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { initDbConnection } from "./db";
|
|||||||
import { keyStoreFactory } from "./keystore/keystore";
|
import { keyStoreFactory } from "./keystore/keystore";
|
||||||
import { formatSmtpConfig, initEnvConfig } from "./lib/config/env";
|
import { formatSmtpConfig, initEnvConfig } from "./lib/config/env";
|
||||||
import { initLogger } from "./lib/logger";
|
import { initLogger } from "./lib/logger";
|
||||||
import { initTelemetry } from "./lib/telemetry/instrumentation";
|
import { initTelemetryInstrumentation } from "./lib/telemetry/instrumentation";
|
||||||
import { queueServiceFactory } from "./queue";
|
import { queueServiceFactory } from "./queue";
|
||||||
import { main } from "./server/app";
|
import { main } from "./server/app";
|
||||||
import { bootstrapCheck } from "./server/boot-strap-check";
|
import { bootstrapCheck } from "./server/boot-strap-check";
|
||||||
@@ -16,7 +16,13 @@ const run = async () => {
|
|||||||
const appCfg = initEnvConfig(logger);
|
const appCfg = initEnvConfig(logger);
|
||||||
|
|
||||||
if (appCfg.OTEL_TELEMETRY_COLLECTION_ENABLED) {
|
if (appCfg.OTEL_TELEMETRY_COLLECTION_ENABLED) {
|
||||||
await initTelemetry({ otlpURL: appCfg.OTEL_COLLECTOR_OTLP_URL });
|
await initTelemetryInstrumentation({
|
||||||
|
otlpURL: appCfg.OTEL_EXPORT_OTLP_ENDPOINT,
|
||||||
|
otlpUser: appCfg.OTEL_COLLECTOR_BASIC_AUTH_USERNAME,
|
||||||
|
otlpPassword: appCfg.OTEL_COLLECTOR_BASIC_AUTH_PASSWORD,
|
||||||
|
otlpPushInterval: appCfg.OTEL_OTLP_PUSH_INTERVAL,
|
||||||
|
exportType: appCfg.OTEL_EXPORT_TYPE
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const db = initDbConnection({
|
const db = initDbConnection({
|
||||||
|
|||||||
@@ -1,8 +1,20 @@
|
|||||||
|
extensions:
|
||||||
|
health_check:
|
||||||
|
pprof:
|
||||||
|
zpages:
|
||||||
|
basicauth/server:
|
||||||
|
htpasswd:
|
||||||
|
inline: |
|
||||||
|
infisical:infisical
|
||||||
|
|
||||||
receivers:
|
receivers:
|
||||||
otlp:
|
otlp:
|
||||||
protocols:
|
protocols:
|
||||||
http:
|
http:
|
||||||
endpoint: 0.0.0.0:4318
|
endpoint: 0.0.0.0:4318
|
||||||
|
auth:
|
||||||
|
authenticator: basicauth/server
|
||||||
|
|
||||||
prometheus:
|
prometheus:
|
||||||
config:
|
config:
|
||||||
scrape_configs:
|
scrape_configs:
|
||||||
@@ -19,17 +31,15 @@ processors:
|
|||||||
exporters:
|
exporters:
|
||||||
prometheus:
|
prometheus:
|
||||||
endpoint: "0.0.0.0:8889"
|
endpoint: "0.0.0.0:8889"
|
||||||
|
auth:
|
||||||
|
authenticator: basicauth/server
|
||||||
resource_to_telemetry_conversion:
|
resource_to_telemetry_conversion:
|
||||||
enabled: true
|
enabled: true
|
||||||
extensions:
|
|
||||||
health_check:
|
|
||||||
pprof:
|
|
||||||
zpages:
|
|
||||||
|
|
||||||
service:
|
service:
|
||||||
extensions: [health_check, pprof, zpages]
|
extensions: [basicauth/server, health_check, pprof, zpages]
|
||||||
pipelines:
|
pipelines:
|
||||||
metrics:
|
metrics:
|
||||||
receivers: [otlp, prometheus]
|
receivers: [otlp]
|
||||||
processors: [batch]
|
processors: [batch]
|
||||||
exporters: [prometheus]
|
exporters: [prometheus]
|
||||||
|
|||||||
@@ -3,3 +3,6 @@ scrape_configs:
|
|||||||
scrape_interval: 30s
|
scrape_interval: 30s
|
||||||
static_configs:
|
static_configs:
|
||||||
- targets: ["otel-collector:8889"]
|
- targets: ["otel-collector:8889"]
|
||||||
|
basic_auth:
|
||||||
|
username: infisical
|
||||||
|
password: infisical
|
||||||
|
|||||||
Reference in New Issue
Block a user