Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit df4e14b

Browse files
author
Jannis Pohlmann
committed
node: Add Elasticsearch logging options
1 parent d52fc43 commit df4e14b

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

node/src/main.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use graph::components::forward;
3434
use graph::prelude::{JsonRpcServer as JsonRpcServerTrait, *};
3535
use graph::util::log::{guarded_logger, logger, register_panic_hook};
3636
use graph_core::{
37-
SubgraphInstanceManager, SubgraphProvider as IpfsSubgraphProvider,
37+
ElasticLoggingConfig, SubgraphInstanceManager, SubgraphProvider as IpfsSubgraphProvider,
3838
SubgraphProviderWithNames as IpfsSubgraphProviderWithNames,
3939
};
4040
use graph_datasource_ethereum::{BlockStreamBuilder, Transport};
@@ -121,6 +121,25 @@ fn async_main() -> impl Future<Item = (), Error = ()> + Send + 'static {
121121
Arg::with_name("debug")
122122
.long("debug")
123123
.help("Enable debug logging"),
124+
).arg(
125+
Arg::with_name("elasticsearch-endpoint")
126+
.long("elasticsearch-endpoint")
127+
.value_name("URL")
128+
.env("ELASTICSEARCH_ENDPOINT")
129+
.help("Elasticsearch endpoint to write subgraph logs to"),
130+
).arg(
131+
Arg::with_name("elasticsearch-user")
132+
.long("elasticsearch-user")
133+
.value_name("USER")
134+
.env("ELASTICSEARCH_USER")
135+
.help("User to use for Elasticsearch logging"),
136+
).arg(
137+
Arg::with_name("elasticsearch-password")
138+
.long("elasticsearch-password")
139+
.value_name("PASSWORD")
140+
.env("ELASTICSEARCH_PASSWORD")
141+
.hide_env_values(true)
142+
.help("Password to use for Elasticsearch logging"),
124143
).get_matches();
125144

126145
// Set up logger
@@ -292,6 +311,16 @@ fn async_main() -> impl Future<Item = (), Error = ()> + Send + 'static {
292311
let block_stream_builder =
293312
BlockStreamBuilder::new(store.clone(), store.clone(), ethereum.clone());
294313

314+
// Optionally, identify the Elasticsearch logging configuration
315+
let elastic_config =
316+
matches
317+
.value_of("elasticsearch-endpoint")
318+
.map(|endpoint| ElasticLoggingConfig {
319+
endpoint: endpoint.into(),
320+
username: matches.value_of("elasticsearch-user").unwrap_or("").into(),
321+
password: matches.value_of("elasticsearch-password").map(|s| s.into()),
322+
});
323+
295324
// Prepare for hosting WASM runtimes and managing subgraph instances
296325
let runtime_host_builder =
297326
WASMRuntimeHostBuilder::new(ethereum.clone(), ipfs_client.clone(), store.clone());
@@ -300,6 +329,7 @@ fn async_main() -> impl Future<Item = (), Error = ()> + Send + 'static {
300329
store.clone(),
301330
runtime_host_builder,
302331
block_stream_builder,
332+
elastic_config,
303333
);
304334

305335
// Create IPFS-based subgraph provider

0 commit comments

Comments
 (0)