feat: support HYPERDX_LOG_LEVEL env var (#66)

This commit is contained in:
Warren 2023-10-18 12:01:44 -07:00 committed by GitHub
parent 76ca910725
commit 389bb3a027
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 147 additions and 8 deletions

View file

@ -0,0 +1,6 @@
---
'@hyperdx/api': patch
'@hyperdx/app': patch
---
feat: support HYPERDX_LOG_LEVEL env var

1
.env
View file

@ -7,5 +7,6 @@ HYPERDX_API_PORT=8000
HYPERDX_API_URL=http://localhost HYPERDX_API_URL=http://localhost
HYPERDX_APP_PORT=8080 HYPERDX_APP_PORT=8080
HYPERDX_APP_URL=http://localhost HYPERDX_APP_URL=http://localhost
HYPERDX_LOG_LEVEL=debug
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 # port is fixed OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 # port is fixed

View file

@ -1 +1,99 @@
version = 1 version = 1
[merge]
# Label to enable Kodiak to merge a PR.
automerge_label = "automerge"
# When disabled, Kodiak will immediately attempt to merge any PR that passes all
# GitHub branch protection requirements.
require_automerge_label = true
# If you're using the "Require signed commits" GitHub Branch Protection setting
# to require commit signatures, "merge" or "squash" are the only compatible options. "rebase" will cause Kodiak to raise a configuration error.
method = "squash" # default: "merge", options: "merge", "squash", "rebase"
# Once a PR is merged, delete the branch. This option behaves like the GitHub
# repository setting "Automatically delete head branches", which automatically
# deletes head branches after pull requests are merged.
delete_branch_on_merge = true # default: false
# If there is a merge conflict, make a comment on the PR and remove the
# automerge label. This option only applies when `merge.require_automerge_label`
# is enabled.
notify_on_conflict = true # default: true
# Don't wait for in-progress status checks on a PR to finish before updating the
# branch.
optimistic_updates = true # default: true
# If a PR is passing all checks and is able to be merged, merge it without
# placing it in the merge queue. This option adds some unfairness where PRs
# waiting in the queue the longest are not served first.
prioritize_ready_to_merge = true # default: false
# Never merge a PR. This option can be used with `update.always` to
# automatically update a PR without merging.
do_not_merge = false # default: false
[merge.message]
# By default (`"github_default"`), GitHub uses the title of a PR's first commit
# for the merge commit title. `"pull_request_title"` uses the PR title for the
# merge commit.
title = "pull_request_title" # default: "github_default", options: "github_default", "pull_request_title"
# By default (`"github_default"`), GitHub combines the titles of a PR's commits
# to create the body text of a merge commit. `"pull_request_body"` uses the
# content of the PR to generate the body content while `"empty"` sets an empty
# body.
body = "pull_request_body" # default: "github_default", options: "github_default", "pull_request_body", "empty"
# Append the Pull Request URL to the merge message. Makes navigating to the PR
# from the commit easier.
#### NOTE: 'true' required for benchmarks in CI:
include_pull_request_url = false # default: false
# Add the PR number to the merge commit title. This setting replicates GitHub's
# behavior of automatically adding the PR number to the title of merges created
# through the UI. This option only applies when `merge.message.title` does not
# equal `"github_default"`.
### NOTE: if this is set to true github links to unrelated OSS issues, which is confusing
include_pr_number = true # default: true
# Control the text used in the merge commit. The GitHub default is markdown, but
# `"plain_text"` or `"html"` can be used to render the pull request body as text
# or HTML. This option only applies when `merge.message.body = "pull_request_body"`.
body_type = "markdown" # default: "markdown", options: "plain_text", "markdown", "html"
# Strip HTML comments (`<!-- some HTML comment -->`) from merge commit body.
# This setting is useful for stripping HTML comments created by PR templates.
# This option only applies when `merge.message.body_type = "markdown"`.
strip_html_comments = true # default: false
# Remove all content before the configured string in the pull request body.
# This setting is useful when we want to include only a part of the pull request
# description as the commit message.
# This option only applies when `merge.message.body_type = "markdown"`.
cut_body_before = "<!-- kodiak-commit-message-body-start: do not remove/edit this line -->"
include_coauthors = true
[update]
# Update a PR whenever out of date with the base branch. The PR will be updated
# regardless of merge requirements (e.g. failing status checks, missing reviews,
# blacklist labels).
#
# Kodiak will only update PRs with the `merge.automerge_label` label or if
# `update.require_automerge_label = false`.
#
# When enabled, _Kodiak will not be able to efficiently update PRs._ If you have
# multiple PRs against a target like `master`, any time a commit is added to
# `master` _all_ of those PRs against `master` will update. For `N` PRs against
# a target you will see at least `N(N-1)/2` updates. If this configuration
# option was disabled you would only see at least `N-1` updates.
always = false # default: false
# When enabled, Kodiak will only update PRs that have an automerge label
# (configured via `merge.automerge_label`). When disable, Kodiak will update any
# PR. This option only applies when `update.always = true`.
require_automerge_label = true # default: true

View file

@ -185,6 +185,14 @@ comprehensive documentation on how we balance between cloud-only and open source
features in the future. In the meantime, we're highly aligned with Gitlab's features in the future. In the meantime, we're highly aligned with Gitlab's
[stewardship model](https://handbook.gitlab.com/handbook/company/stewardship/). [stewardship model](https://handbook.gitlab.com/handbook/company/stewardship/).
## Frequently Asked Questions
#### How to suppress all logs from HyperDX itself ?
To suppress logs of a service, you can comment out the `HYPERDX_API_KEY`
environment variable in the docker-compose.yml file. The alternative is to set
the `HYPERDX_LOG_LEVEL` environment variable to 'error' to only log errors.
## Contact ## Contact
- [Open an Issue](https://github.com/hyperdxio/hyperdx/issues/new) - [Open an Issue](https://github.com/hyperdxio/hyperdx/issues/new)

View file

@ -9,8 +9,9 @@ services:
environment: environment:
HYPERDX_API_KEY: ${HYPERDX_API_KEY} HYPERDX_API_KEY: ${HYPERDX_API_KEY}
HYPERDX_ENABLE_ADVANCED_NETWORK_CAPTURE: 1 HYPERDX_ENABLE_ADVANCED_NETWORK_CAPTURE: 1
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318 OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
OTEL_LOG_LEVEL: ERROR OTEL_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
OTEL_SERVICE_NAME: hdx-oss-dev-miner OTEL_SERVICE_NAME: hdx-oss-dev-miner
volumes: volumes:
- ./packages/miner/src:/app/src - ./packages/miner/src:/app/src
@ -27,6 +28,7 @@ services:
- ./docker/hostmetrics/config.dev.yaml:/etc/otelcol-contrib/config.yaml - ./docker/hostmetrics/config.dev.yaml:/etc/otelcol-contrib/config.yaml
environment: environment:
HYPERDX_API_KEY: ${HYPERDX_API_KEY} HYPERDX_API_KEY: ${HYPERDX_API_KEY}
OTEL_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
OTEL_SERVICE_NAME: hostmetrics OTEL_SERVICE_NAME: hostmetrics
restart: always restart: always
networks: networks:
@ -44,7 +46,7 @@ services:
- 8686:8686 # healthcheck - 8686:8686 # healthcheck
environment: environment:
RUST_BACKTRACE: full RUST_BACKTRACE: full
VECTOR_LOG: debug VECTOR_LOG: ${HYPERDX_LOG_LEVEL}
VECTOR_OPENSSL_LEGACY_PROVIDER: false VECTOR_OPENSSL_LEGACY_PROVIDER: false
restart: always restart: always
networks: networks:
@ -72,6 +74,8 @@ services:
build: build:
context: ./docker/otel-collector context: ./docker/otel-collector
target: dev target: dev
environment:
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
volumes: volumes:
- ./docker/otel-collector/config.yaml:/etc/otelcol-contrib/config.yaml - ./docker/otel-collector/config.yaml:/etc/otelcol-contrib/config.yaml
ports: ports:
@ -100,6 +104,7 @@ services:
CLICKHOUSE_PASSWORD: aggregator CLICKHOUSE_PASSWORD: aggregator
CLICKHOUSE_USER: aggregator CLICKHOUSE_USER: aggregator
FRONTEND_URL: 'http://localhost:8080' # need to be localhost (CORS) FRONTEND_URL: 'http://localhost:8080' # need to be localhost (CORS)
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
MONGO_URI: 'mongodb://db:27017/hyperdx' MONGO_URI: 'mongodb://db:27017/hyperdx'
NODE_ENV: development NODE_ENV: development
PORT: 8001 PORT: 8001
@ -132,6 +137,7 @@ services:
HDX_NODE_BETA_MODE: 0 HDX_NODE_BETA_MODE: 0
HDX_NODE_CONSOLE_CAPTURE: 1 HDX_NODE_CONSOLE_CAPTURE: 1
HYPERDX_API_KEY: ${HYPERDX_API_KEY} HYPERDX_API_KEY: ${HYPERDX_API_KEY}
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
INGESTOR_API_URL: 'http://ingestor:8002' INGESTOR_API_URL: 'http://ingestor:8002'
MINER_API_URL: 'http://miner:5123' MINER_API_URL: 'http://miner:5123'
MONGO_URI: 'mongodb://db:27017/hyperdx' MONGO_URI: 'mongodb://db:27017/hyperdx'
@ -169,6 +175,7 @@ services:
HDX_NODE_BETA_MODE: 1 HDX_NODE_BETA_MODE: 1
HDX_NODE_CONSOLE_CAPTURE: 1 HDX_NODE_CONSOLE_CAPTURE: 1
HYPERDX_API_KEY: ${HYPERDX_API_KEY} HYPERDX_API_KEY: ${HYPERDX_API_KEY}
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
INGESTOR_API_URL: 'http://ingestor:8002' INGESTOR_API_URL: 'http://ingestor:8002'
MINER_API_URL: 'http://miner:5123' MINER_API_URL: 'http://miner:5123'
MONGO_URI: 'mongodb://db:27017/hyperdx' MONGO_URI: 'mongodb://db:27017/hyperdx'

View file

@ -6,8 +6,9 @@ services:
environment: environment:
HYPERDX_API_KEY: ${HYPERDX_API_KEY} HYPERDX_API_KEY: ${HYPERDX_API_KEY}
HYPERDX_ENABLE_ADVANCED_NETWORK_CAPTURE: 1 HYPERDX_ENABLE_ADVANCED_NETWORK_CAPTURE: 1
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318 OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
OTEL_LOG_LEVEL: ERROR OTEL_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
OTEL_SERVICE_NAME: hdx-oss-miner OTEL_SERVICE_NAME: hdx-oss-miner
ports: ports:
- 5123:5123 - 5123:5123
@ -18,6 +19,7 @@ services:
container_name: hdx-oss-hostmetrics container_name: hdx-oss-hostmetrics
environment: environment:
HYPERDX_API_KEY: ${HYPERDX_API_KEY} HYPERDX_API_KEY: ${HYPERDX_API_KEY}
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
OTEL_SERVICE_NAME: hostmetrics OTEL_SERVICE_NAME: hostmetrics
restart: always restart: always
networks: networks:
@ -32,7 +34,7 @@ services:
- 8686:8686 # healthcheck - 8686:8686 # healthcheck
environment: environment:
RUST_BACKTRACE: full RUST_BACKTRACE: full
VECTOR_LOG: debug VECTOR_LOG: ${HYPERDX_LOG_LEVEL}
VECTOR_OPENSSL_LEGACY_PROVIDER: false VECTOR_OPENSSL_LEGACY_PROVIDER: false
restart: always restart: always
networks: networks:
@ -58,6 +60,8 @@ services:
otel-collector: otel-collector:
image: ${IMAGE_NAME}:${IMAGE_VERSION}-otel-collector image: ${IMAGE_NAME}:${IMAGE_VERSION}-otel-collector
container_name: hdx-oss-otel-collector container_name: hdx-oss-otel-collector
environment:
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
ports: ports:
- '13133:13133' # health_check extension - '13133:13133' # health_check extension
- '1888:1888' # pprof extension - '1888:1888' # pprof extension
@ -81,6 +85,7 @@ services:
CLICKHOUSE_PASSWORD: aggregator CLICKHOUSE_PASSWORD: aggregator
CLICKHOUSE_USER: aggregator CLICKHOUSE_USER: aggregator
FRONTEND_URL: ${HYPERDX_APP_URL}:${HYPERDX_APP_PORT} # need to be localhost (CORS) FRONTEND_URL: ${HYPERDX_APP_URL}:${HYPERDX_APP_PORT} # need to be localhost (CORS)
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
MONGO_URI: 'mongodb://db:27017/hyperdx' MONGO_URI: 'mongodb://db:27017/hyperdx'
NODE_ENV: development NODE_ENV: development
PORT: 8001 PORT: 8001
@ -108,6 +113,7 @@ services:
HDX_NODE_BETA_MODE: 0 HDX_NODE_BETA_MODE: 0
HDX_NODE_CONSOLE_CAPTURE: 1 HDX_NODE_CONSOLE_CAPTURE: 1
HYPERDX_API_KEY: ${HYPERDX_API_KEY} HYPERDX_API_KEY: ${HYPERDX_API_KEY}
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
INGESTOR_API_URL: 'http://ingestor:8002' INGESTOR_API_URL: 'http://ingestor:8002'
MINER_API_URL: 'http://miner:5123' MINER_API_URL: 'http://miner:5123'
MONGO_URI: 'mongodb://db:27017/hyperdx' MONGO_URI: 'mongodb://db:27017/hyperdx'
@ -140,6 +146,7 @@ services:
HDX_NODE_BETA_MODE: 1 HDX_NODE_BETA_MODE: 1
HDX_NODE_CONSOLE_CAPTURE: 1 HDX_NODE_CONSOLE_CAPTURE: 1
HYPERDX_API_KEY: ${HYPERDX_API_KEY} HYPERDX_API_KEY: ${HYPERDX_API_KEY}
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
INGESTOR_API_URL: 'http://ingestor:8002' INGESTOR_API_URL: 'http://ingestor:8002'
MINER_API_URL: 'http://miner:5123' MINER_API_URL: 'http://miner:5123'
MONGO_URI: 'mongodb://db:27017/hyperdx' MONGO_URI: 'mongodb://db:27017/hyperdx'

View file

@ -21,7 +21,7 @@ receivers:
network: network:
exporters: exporters:
logging: logging:
loglevel: debug loglevel: ${env:HYPERDX_LOG_LEVEL}
otlphttp: otlphttp:
endpoint: 'http://otel-collector:4318' endpoint: 'http://otel-collector:4318'
headers: headers:

View file

@ -39,7 +39,7 @@ processors:
check_interval: 5s check_interval: 5s
exporters: exporters:
logging: logging:
loglevel: debug loglevel: ${env:HYPERDX_LOG_LEVEL}
logzio/traces: logzio/traces:
account_token: 'X' # required but we don't use it account_token: 'X' # required but we don't use it
endpoint: 'http://ingestor:8002?hdx_platform=otel-traces' endpoint: 'http://ingestor:8002?hdx_platform=otel-traces'

View file

@ -11,6 +11,7 @@ export const COOKIE_DOMAIN = env.COOKIE_DOMAIN as string; // prod ONLY
export const EXPRESS_SESSION_SECRET = env.EXPRESS_SESSION_SECRET as string; export const EXPRESS_SESSION_SECRET = env.EXPRESS_SESSION_SECRET as string;
export const FRONTEND_URL = env.FRONTEND_URL as string; export const FRONTEND_URL = env.FRONTEND_URL as string;
export const HYPERDX_API_KEY = env.HYPERDX_API_KEY as string; export const HYPERDX_API_KEY = env.HYPERDX_API_KEY as string;
export const HYPERDX_LOG_LEVEL = env.HYPERDX_LOG_LEVEL as string;
export const INGESTOR_API_URL = env.INGESTOR_API_URL as string; export const INGESTOR_API_URL = env.INGESTOR_API_URL as string;
export const IS_CI = NODE_ENV === 'ci'; export const IS_CI = NODE_ENV === 'ci';
export const IS_DEV = NODE_ENV === 'development'; export const IS_DEV = NODE_ENV === 'development';

View file

@ -5,6 +5,7 @@ import winston, { addColors } from 'winston';
import { import {
APP_TYPE, APP_TYPE,
HYPERDX_API_KEY, HYPERDX_API_KEY,
HYPERDX_LOG_LEVEL,
INGESTOR_API_URL, INGESTOR_API_URL,
IS_PROD, IS_PROD,
} from '../config'; } from '../config';
@ -20,7 +21,7 @@ addColors({
silly: 'cyan', silly: 'cyan',
}); });
const MAX_LEVEL = IS_PROD ? 'debug' : 'debug'; const MAX_LEVEL = HYPERDX_LOG_LEVEL ?? 'debug';
const DEFAULT_FORMAT = winston.format.combine( const DEFAULT_FORMAT = winston.format.combine(
winston.format.errors({ stack: true }), winston.format.errors({ stack: true }),
winston.format.json(), winston.format.json(),
@ -34,6 +35,7 @@ const hyperdxTransport = HYPERDX_API_KEY
: null; : null;
export const expressLogger = expressWinston.logger({ export const expressLogger = expressWinston.logger({
level: MAX_LEVEL,
format: DEFAULT_FORMAT, format: DEFAULT_FORMAT,
msg: IS_PROD msg: IS_PROD
? undefined ? undefined

View file

@ -2,6 +2,7 @@ from typing import List
import hashlib import hashlib
import json import json
import logging import logging
import os
import time import time
from drain3 import TemplateMiner from drain3 import TemplateMiner
@ -16,8 +17,16 @@ API_VERSION = "0.0.1"
app = FastAPI() app = FastAPI()
def get_logging_level():
try:
return getattr(logging, os.environ.get("HYPERDX_LOG_LEVEL", "DEBUG").upper())
except Exception:
return logging.DEBUG
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG) logger.setLevel(get_logging_level())
def get_template_miner(): def get_template_miner():