Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[promtail] log: simplify log, only print hash #7405

Merged
merged 2 commits into from
Oct 13, 2022

Conversation

liguozhong
Copy link
Contributor

@liguozhong liguozhong commented Oct 13, 2022

What this PR does / why we need it:
When promtail reload config.yaml, simplify log print, only print hash.

Hash function Use the same hash function as prometheus.
/github.com/prometheus/prometheus/model/labels/labels.go

import  "github.com/cespare/xxhash/v2"

func (ls Labels) HashWithoutLabels(b []byte, names ...string) (uint64, []byte) {
	...
	return xxhash.Sum64(b), b
}

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:
level=info ts=2022-10-12T14:40:05.323235834Z caller=promtail.go:122 msg="Reloading configuration file" newConf="server:\n http_listen_network: tcp\n http_listen_address: \"\"\n http_listen_port: 9082\n http_listen_conn_limit: 0\n grpc_listen_network: tcp\n grpc_listen_address: \"\"\n grpc_listen_port: 0\n grpc_listen_conn_limit: 0\n tls_cipher_suites: \"\"\n tls_min_version: \"\"\n http_tls_config:\n cert_file: \"\"\n key_file: \"\"\n client_auth_type: \"\"\n client_ca_file: \"\"\n grpc_tls_config:\n cert_file: \"\"\n key_file: \"\"\n client_auth_type: \"\"\n client_ca_file: \"\"\n register_instrumentation: true\n graceful_shutdown_timeout: 30s\n http_server_read_timeout: 30s\n http_server_write_timeout: 30s\n http_server_idle_timeout: 2m0s\n grpc_server_max_recv_msg_size: 4194304\n grpc_server_max_send_msg_size: 4194304\n grpc_server_max_concurrent_streams: 100\n grpc_server_max_connection_idle: 2562047h47m16.854775807s\n grpc_server_max_connection_age: 2562047h47m16.854775807s\n grpc_server_max_connection_age_grace: 2562047h47m16.854775807s\n grpc_server_keepalive_time: 2h0m0s\n grpc_server_keepalive_timeout: 20s\n grpc_server_min_time_between_pings: 5m0s\n grpc_server_ping_without_stream_allowed: false\n log_format: logfmt\n log_level: info\n log_source_ips_enabled: false\n log_source_ips_header: \"\"\n log_source_ips_regex: \"\"\n log_request_at_info_level_enabled: false\n http_path_prefix: \"\"\n external_url: \"\"\n health_check_target: null\n disable: false\n enable_runtime_reload: false\nclient:\n url: \"\"\n batchwait: 1s\n batchsize: 1048576\n follow_redirects: false\n enable_http2: false\n backoff_config:\n min_period: 500ms\n max_period: 5m0s\n max_retries: 10\n timeout: 10s\n tenant_id: \"\"\n stream_lag_labels: \"\"\nclients:\n- url: http://localhost:3100/loki/api/v1/push\n batchwait: 1s\n batchsize: 1048576\n follow_redirects: false\n enable_http2: false\n backoff_config:\n min_period: 100ms\n max_period: 10s\n max_retries: 1000\n timeout: 10s\n tenant_id: docker\n stream_lag_labels: \"\"\npositions:\n sync_period: 10s\n filename: /tmp/positions.yaml\n ignore_invalid_yaml: false\nscrape_configs:\n- job_name: generated-logs\n pipeline_stages:\n - json:\n expressions:\n datetime: datetime\n http_method: method\n http_status: status\n - labels:\n ʊmlaʊt: hi\n static_configs:\n - targets:\n - localhost\n labels:\n __path__: /tmp/random\n job: generated-logs\ntarget_config:\n sync_period: 10s\n stdin: false\nlimits_config:\n readline_rate: 10000\n readline_burst: 10000\n readline_rate_drop: true\n max_streams: 0\n"

Checklist

  • Reviewed the CONTRIBUTING.md guide
  • Documentation added
  • Tests updated
  • CHANGELOG.md updated
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/upgrading/_index.md

@liguozhong liguozhong requested a review from a team as a code owner October 13, 2022 05:48
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@@ -119,7 +120,7 @@ func (p *Promtail) reloadConfig(cfg *config.Config) error {
return errConfigNotChange
}
newConf := cfg.String()
level.Info(p.logger).Log("msg", "Reloading configuration file", "newConf", newConf)
level.Info(p.logger).Log("msg", "Reloading configuration file", "newConf hash", xxhash.Sum64String(newConf))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you use xxhash here? Wouldn't md5 be easier for a user to check against?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌,you are right

Copy link
Contributor

@kavirajk kavirajk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually good idea. thanks @liguozhong.

Even if we want the actual configs values to check or anything we can always get it via /config.

Happy to merge if other maintainers have no issues

@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@dannykopping dannykopping merged commit 61bbe15 into grafana:main Oct 13, 2022
lxwzy pushed a commit to lxwzy/loki that referenced this pull request Nov 7, 2022
changhyuni pushed a commit to changhyuni/loki that referenced this pull request Nov 8, 2022
Abuelodelanada pushed a commit to canonical/loki that referenced this pull request Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants