Skip to content

Commit 389bb3a

Browse files
authored
feat: support HYPERDX_LOG_LEVEL env var (#66)
1 parent 76ca910 commit 389bb3a

File tree

11 files changed

+147
-8
lines changed

11 files changed

+147
-8
lines changed

.changeset/calm-plums-hug.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@hyperdx/api': patch
3+
'@hyperdx/app': patch
4+
---
5+
6+
feat: support HYPERDX_LOG_LEVEL env var

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ HYPERDX_API_PORT=8000
77
HYPERDX_API_URL=http://localhost
88
HYPERDX_APP_PORT=8080
99
HYPERDX_APP_URL=http://localhost
10+
HYPERDX_LOG_LEVEL=debug
1011
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 # port is fixed
1112

.kodiak.toml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,99 @@
11
version = 1
2+
3+
[merge]
4+
# Label to enable Kodiak to merge a PR.
5+
automerge_label = "automerge"
6+
7+
# When disabled, Kodiak will immediately attempt to merge any PR that passes all
8+
# GitHub branch protection requirements.
9+
require_automerge_label = true
10+
11+
# If you're using the "Require signed commits" GitHub Branch Protection setting
12+
# to require commit signatures, "merge" or "squash" are the only compatible options. "rebase" will cause Kodiak to raise a configuration error.
13+
method = "squash" # default: "merge", options: "merge", "squash", "rebase"
14+
15+
# Once a PR is merged, delete the branch. This option behaves like the GitHub
16+
# repository setting "Automatically delete head branches", which automatically
17+
# deletes head branches after pull requests are merged.
18+
delete_branch_on_merge = true # default: false
19+
20+
# If there is a merge conflict, make a comment on the PR and remove the
21+
# automerge label. This option only applies when `merge.require_automerge_label`
22+
# is enabled.
23+
notify_on_conflict = true # default: true
24+
25+
# Don't wait for in-progress status checks on a PR to finish before updating the
26+
# branch.
27+
optimistic_updates = true # default: true
28+
29+
# If a PR is passing all checks and is able to be merged, merge it without
30+
# placing it in the merge queue. This option adds some unfairness where PRs
31+
# waiting in the queue the longest are not served first.
32+
prioritize_ready_to_merge = true # default: false
33+
34+
# Never merge a PR. This option can be used with `update.always` to
35+
# automatically update a PR without merging.
36+
do_not_merge = false # default: false
37+
38+
[merge.message]
39+
# By default (`"github_default"`), GitHub uses the title of a PR's first commit
40+
# for the merge commit title. `"pull_request_title"` uses the PR title for the
41+
# merge commit.
42+
title = "pull_request_title" # default: "github_default", options: "github_default", "pull_request_title"
43+
44+
# By default (`"github_default"`), GitHub combines the titles of a PR's commits
45+
# to create the body text of a merge commit. `"pull_request_body"` uses the
46+
# content of the PR to generate the body content while `"empty"` sets an empty
47+
# body.
48+
body = "pull_request_body" # default: "github_default", options: "github_default", "pull_request_body", "empty"
49+
50+
# Append the Pull Request URL to the merge message. Makes navigating to the PR
51+
# from the commit easier.
52+
#### NOTE: 'true' required for benchmarks in CI:
53+
include_pull_request_url = false # default: false
54+
55+
# Add the PR number to the merge commit title. This setting replicates GitHub's
56+
# behavior of automatically adding the PR number to the title of merges created
57+
# through the UI. This option only applies when `merge.message.title` does not
58+
# equal `"github_default"`.
59+
### NOTE: if this is set to true github links to unrelated OSS issues, which is confusing
60+
include_pr_number = true # default: true
61+
62+
# Control the text used in the merge commit. The GitHub default is markdown, but
63+
# `"plain_text"` or `"html"` can be used to render the pull request body as text
64+
# or HTML. This option only applies when `merge.message.body = "pull_request_body"`.
65+
body_type = "markdown" # default: "markdown", options: "plain_text", "markdown", "html"
66+
67+
# Strip HTML comments (`<!-- some HTML comment -->`) from merge commit body.
68+
# This setting is useful for stripping HTML comments created by PR templates.
69+
# This option only applies when `merge.message.body_type = "markdown"`.
70+
strip_html_comments = true # default: false
71+
72+
# Remove all content before the configured string in the pull request body.
73+
# This setting is useful when we want to include only a part of the pull request
74+
# description as the commit message.
75+
# This option only applies when `merge.message.body_type = "markdown"`.
76+
cut_body_before = "<!-- kodiak-commit-message-body-start: do not remove/edit this line -->"
77+
78+
include_coauthors = true
79+
80+
[update]
81+
82+
# Update a PR whenever out of date with the base branch. The PR will be updated
83+
# regardless of merge requirements (e.g. failing status checks, missing reviews,
84+
# blacklist labels).
85+
#
86+
# Kodiak will only update PRs with the `merge.automerge_label` label or if
87+
# `update.require_automerge_label = false`.
88+
#
89+
# When enabled, _Kodiak will not be able to efficiently update PRs._ If you have
90+
# multiple PRs against a target like `master`, any time a commit is added to
91+
# `master` _all_ of those PRs against `master` will update. For `N` PRs against
92+
# a target you will see at least `N(N-1)/2` updates. If this configuration
93+
# option was disabled you would only see at least `N-1` updates.
94+
always = false # default: false
95+
96+
# When enabled, Kodiak will only update PRs that have an automerge label
97+
# (configured via `merge.automerge_label`). When disable, Kodiak will update any
98+
# PR. This option only applies when `update.always = true`.
99+
require_automerge_label = true # default: true

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ comprehensive documentation on how we balance between cloud-only and open source
185185
features in the future. In the meantime, we're highly aligned with Gitlab's
186186
[stewardship model](https://handbook.gitlab.com/handbook/company/stewardship/).
187187

188+
## Frequently Asked Questions
189+
190+
#### How to suppress all logs from HyperDX itself ?
191+
192+
To suppress logs of a service, you can comment out the `HYPERDX_API_KEY`
193+
environment variable in the docker-compose.yml file. The alternative is to set
194+
the `HYPERDX_LOG_LEVEL` environment variable to 'error' to only log errors.
195+
188196
## Contact
189197

190198
- [Open an Issue](https://github.com/hyperdxio/hyperdx/issues/new)

docker-compose.dev.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ services:
99
environment:
1010
HYPERDX_API_KEY: ${HYPERDX_API_KEY}
1111
HYPERDX_ENABLE_ADVANCED_NETWORK_CAPTURE: 1
12+
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
1213
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
13-
OTEL_LOG_LEVEL: ERROR
14+
OTEL_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
1415
OTEL_SERVICE_NAME: hdx-oss-dev-miner
1516
volumes:
1617
- ./packages/miner/src:/app/src
@@ -27,6 +28,7 @@ services:
2728
- ./docker/hostmetrics/config.dev.yaml:/etc/otelcol-contrib/config.yaml
2829
environment:
2930
HYPERDX_API_KEY: ${HYPERDX_API_KEY}
31+
OTEL_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
3032
OTEL_SERVICE_NAME: hostmetrics
3133
restart: always
3234
networks:
@@ -44,7 +46,7 @@ services:
4446
- 8686:8686 # healthcheck
4547
environment:
4648
RUST_BACKTRACE: full
47-
VECTOR_LOG: debug
49+
VECTOR_LOG: ${HYPERDX_LOG_LEVEL}
4850
VECTOR_OPENSSL_LEGACY_PROVIDER: false
4951
restart: always
5052
networks:
@@ -72,6 +74,8 @@ services:
7274
build:
7375
context: ./docker/otel-collector
7476
target: dev
77+
environment:
78+
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
7579
volumes:
7680
- ./docker/otel-collector/config.yaml:/etc/otelcol-contrib/config.yaml
7781
ports:
@@ -100,6 +104,7 @@ services:
100104
CLICKHOUSE_PASSWORD: aggregator
101105
CLICKHOUSE_USER: aggregator
102106
FRONTEND_URL: 'http://localhost:8080' # need to be localhost (CORS)
107+
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
103108
MONGO_URI: 'mongodb://db:27017/hyperdx'
104109
NODE_ENV: development
105110
PORT: 8001
@@ -132,6 +137,7 @@ services:
132137
HDX_NODE_BETA_MODE: 0
133138
HDX_NODE_CONSOLE_CAPTURE: 1
134139
HYPERDX_API_KEY: ${HYPERDX_API_KEY}
140+
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
135141
INGESTOR_API_URL: 'http://ingestor:8002'
136142
MINER_API_URL: 'http://miner:5123'
137143
MONGO_URI: 'mongodb://db:27017/hyperdx'
@@ -169,6 +175,7 @@ services:
169175
HDX_NODE_BETA_MODE: 1
170176
HDX_NODE_CONSOLE_CAPTURE: 1
171177
HYPERDX_API_KEY: ${HYPERDX_API_KEY}
178+
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
172179
INGESTOR_API_URL: 'http://ingestor:8002'
173180
MINER_API_URL: 'http://miner:5123'
174181
MONGO_URI: 'mongodb://db:27017/hyperdx'

docker-compose.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ services:
66
environment:
77
HYPERDX_API_KEY: ${HYPERDX_API_KEY}
88
HYPERDX_ENABLE_ADVANCED_NETWORK_CAPTURE: 1
9+
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
910
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
10-
OTEL_LOG_LEVEL: ERROR
11+
OTEL_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
1112
OTEL_SERVICE_NAME: hdx-oss-miner
1213
ports:
1314
- 5123:5123
@@ -18,6 +19,7 @@ services:
1819
container_name: hdx-oss-hostmetrics
1920
environment:
2021
HYPERDX_API_KEY: ${HYPERDX_API_KEY}
22+
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
2123
OTEL_SERVICE_NAME: hostmetrics
2224
restart: always
2325
networks:
@@ -32,7 +34,7 @@ services:
3234
- 8686:8686 # healthcheck
3335
environment:
3436
RUST_BACKTRACE: full
35-
VECTOR_LOG: debug
37+
VECTOR_LOG: ${HYPERDX_LOG_LEVEL}
3638
VECTOR_OPENSSL_LEGACY_PROVIDER: false
3739
restart: always
3840
networks:
@@ -58,6 +60,8 @@ services:
5860
otel-collector:
5961
image: ${IMAGE_NAME}:${IMAGE_VERSION}-otel-collector
6062
container_name: hdx-oss-otel-collector
63+
environment:
64+
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
6165
ports:
6266
- '13133:13133' # health_check extension
6367
- '1888:1888' # pprof extension
@@ -81,6 +85,7 @@ services:
8185
CLICKHOUSE_PASSWORD: aggregator
8286
CLICKHOUSE_USER: aggregator
8387
FRONTEND_URL: ${HYPERDX_APP_URL}:${HYPERDX_APP_PORT} # need to be localhost (CORS)
88+
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
8489
MONGO_URI: 'mongodb://db:27017/hyperdx'
8590
NODE_ENV: development
8691
PORT: 8001
@@ -108,6 +113,7 @@ services:
108113
HDX_NODE_BETA_MODE: 0
109114
HDX_NODE_CONSOLE_CAPTURE: 1
110115
HYPERDX_API_KEY: ${HYPERDX_API_KEY}
116+
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
111117
INGESTOR_API_URL: 'http://ingestor:8002'
112118
MINER_API_URL: 'http://miner:5123'
113119
MONGO_URI: 'mongodb://db:27017/hyperdx'
@@ -140,6 +146,7 @@ services:
140146
HDX_NODE_BETA_MODE: 1
141147
HDX_NODE_CONSOLE_CAPTURE: 1
142148
HYPERDX_API_KEY: ${HYPERDX_API_KEY}
149+
HYPERDX_LOG_LEVEL: ${HYPERDX_LOG_LEVEL}
143150
INGESTOR_API_URL: 'http://ingestor:8002'
144151
MINER_API_URL: 'http://miner:5123'
145152
MONGO_URI: 'mongodb://db:27017/hyperdx'

docker/hostmetrics/config.dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ receivers:
2121
network:
2222
exporters:
2323
logging:
24-
loglevel: debug
24+
loglevel: ${env:HYPERDX_LOG_LEVEL}
2525
otlphttp:
2626
endpoint: 'http://otel-collector:4318'
2727
headers:

docker/otel-collector/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ processors:
3939
check_interval: 5s
4040
exporters:
4141
logging:
42-
loglevel: debug
42+
loglevel: ${env:HYPERDX_LOG_LEVEL}
4343
logzio/traces:
4444
account_token: 'X' # required but we don't use it
4545
endpoint: 'http://ingestor:8002?hdx_platform=otel-traces'

packages/api/src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const COOKIE_DOMAIN = env.COOKIE_DOMAIN as string; // prod ONLY
1111
export const EXPRESS_SESSION_SECRET = env.EXPRESS_SESSION_SECRET as string;
1212
export const FRONTEND_URL = env.FRONTEND_URL as string;
1313
export const HYPERDX_API_KEY = env.HYPERDX_API_KEY as string;
14+
export const HYPERDX_LOG_LEVEL = env.HYPERDX_LOG_LEVEL as string;
1415
export const INGESTOR_API_URL = env.INGESTOR_API_URL as string;
1516
export const IS_CI = NODE_ENV === 'ci';
1617
export const IS_DEV = NODE_ENV === 'development';

packages/api/src/utils/logger.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import winston, { addColors } from 'winston';
55
import {
66
APP_TYPE,
77
HYPERDX_API_KEY,
8+
HYPERDX_LOG_LEVEL,
89
INGESTOR_API_URL,
910
IS_PROD,
1011
} from '../config';
@@ -20,7 +21,7 @@ addColors({
2021
silly: 'cyan',
2122
});
2223

23-
const MAX_LEVEL = IS_PROD ? 'debug' : 'debug';
24+
const MAX_LEVEL = HYPERDX_LOG_LEVEL ?? 'debug';
2425
const DEFAULT_FORMAT = winston.format.combine(
2526
winston.format.errors({ stack: true }),
2627
winston.format.json(),
@@ -34,6 +35,7 @@ const hyperdxTransport = HYPERDX_API_KEY
3435
: null;
3536

3637
export const expressLogger = expressWinston.logger({
38+
level: MAX_LEVEL,
3739
format: DEFAULT_FORMAT,
3840
msg: IS_PROD
3941
? undefined

packages/miner/src/main.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import hashlib
33
import json
44
import logging
5+
import os
56
import time
67

78
from drain3 import TemplateMiner
@@ -16,8 +17,16 @@
1617

1718
app = FastAPI()
1819

20+
21+
def get_logging_level():
22+
try:
23+
return getattr(logging, os.environ.get("HYPERDX_LOG_LEVEL", "DEBUG").upper())
24+
except Exception:
25+
return logging.DEBUG
26+
27+
1928
logger = logging.getLogger(__name__)
20-
logger.setLevel(logging.DEBUG)
29+
logger.setLevel(get_logging_level())
2130

2231

2332
def get_template_miner():

0 commit comments

Comments
 (0)