监控

您可以使用与在本地运行 Neo4j 相同的机制来监控在 Kubernetes 上运行的 Neo4j DBMS。

日志记录

使用 Helm 图表时,Neo4j 日志输出将写入到 /logs 目录下的文件中。此目录挂载到一个 PersistentVolume 上,以便在 Pod 被移动或重启时持久化日志。有关 Neo4j 日志记录的完整详细信息,请参阅 Neo4j 日志记录

  • 要查看 Neo4j 用户日志 (neo4j.log),请使用命令 kubectl exec

    跟踪 neo4j.log
    kubectl exec <neo4j-pod-name> -- tail -f /logs/neo4j.log
  • 要从 Neo4j 实例复制日志文件,请使用 kubectl cp

    复制所有日志
    $ kubectl cp :/logs neo4j-logs/
    $ ls neo4j-logs
    debug.log       neo4j.log       query.log       security.log

日志收集

可以使用 Fluentd (https://www.fluentd.org) 或 Logstash (https://elastic.ac.cn/logstash) 等工具,从日志文件中收集 Neo4j 日志输出并将其发送到统一位置。我们建议将这些工具作为 Neo4j Pod 中的“Sidecar”容器或单独的 DaemonSet 来运行。

指标

如果 Neo4j 配置为侦听 Graphite、JMX 或 Prometheus 连接以获取指标,则可以按照 访问 Neo4j 中的说明访问这些服务。

Helm 图表支持标准的 Neo4j 指标配置设置,例如

# To listen for Prometheus connections
# Neo4j configuration (yaml format)
config:
  server.metrics.prometheus.enabled: "true"
  server.metrics.prometheus.endpoint: "0.0.0.0:2004"
# To publish Graphite connections
# Neo4j configuration (yaml format)
config:
  server.metrics.graphite.enabled: "true"
  server.metrics.graphite.interval: "3s"
  server.metrics.graphite.server: "graphite.default.svc.cluster.local:2003"
# To write CSV metrics
# Neo4j configuration (yaml format)
config:
  server.metrics.csv.enabled: "true"
  server.metrics.csv.interval: "10s"
# To enable JMX
# Neo4j configuration (yaml format)
config:
  server.metrics.jmx.enabled: "true"

有关更多信息和示例,请参阅 Neo4j 指标