监控 Docker Compose 设置中的 Neo4j 实例
除了运行独立的 Neo4j 容器并使用注入的代理进程对其进行监控外,声明式的 Docker Compose 使得将代理作为挂载的可执行文件进行设置或使用 Neo4j 映像中捆绑的代理使用自定义入口点变得更加容易,如下所示。
entrypoint.sh
#!/bin/bash -eu
/startup/docker-entrypoint.sh neo4j &
tar -xzf products/neo4j-ops-manager-agent-*-linux-amd64.tar.gz --strip-components 1 \
&& mv bin/agent /bin/agent \
&& agent console -s
db.service.yaml
test_local:
hostname: test_local
image: ${NEO4J_IMAGE}
entrypoint: /custom/entrypoint.sh
depends_on:
server: # server service if running in the same composed environment
condition: service_healthy
networks: # same network as server service if in the same composed environment
- lan
environment:
CONFIG_SERVER_GRPC_ADDRESS: "server:9090"
CONFIG_SERVER_HTTP_ADDRESS: "https://server:8080"
CONFIG_TLS_TRUSTED_CERTS: "/certificates/certs/ca-chain.pem"
# CONFIG_TLS_CLIENT_CERT: "test_local.cert.pem" # agent cert for mTLS authentication
# CONFIG_TLS_CLIENT_KEY: "test_local.key.pem" # agent key for mTLS authentication
CONFIG_LOG_LEVEL: "debug"
CONFIG_INSTANCE_1_NAME: "test_local"
CONFIG_INSTANCE_1_BOLT_URI: "bolt://localhost:7687"
CONFIG_INSTANCE_1_BOLT_USERNAME: "neo4j"
CONFIG_INSTANCE_1_BOLT_PASSWORD: "passw0rd"
CONFIG_INSTANCE_1_QUERY_LOG_PORT: "9500"
CONFIG_INSTANCE_1_LOG_CONFIG_PATH: "/var/lib/neo4j/conf/server-logs.xml"
CONFIG_INSTANCE_1_QUERY_LOG_MIN_DURATION: "100"
NEO4J_ACCEPT_LICENSE_AGREEMENT: "yes"
NEO4J_AUTH: neo4j/passw0rd
NEO4J_EDITION: "enterprise"
NEO4J_server_metrics_prometheus_enabled: "true"
NEO4J_server_metrics_prometheus_endpoint: "localhost:2004"
NEO4J_server_metrics_filter: "*"
volumes:
- /path/to/custom/entrypoint:/custom
# - /path/to/agent/bin:/var/lib/neo4j/bin
上面的 Neo4j 实例作为 Docker Compose 服务可以与类似的实例一起作为测试和本地环境中的单个 Compose 部署的一部分使用。