Observability

    Artifact is distribution/agent/target/apache-shardingsphere-${latest.release.version}-shardingsphere-agent-bin.tar.gz

    Directory structure

    Create agent directory, and unzip agent distribution package to the directory.

    1. tar -zxvf apache-shardingsphere-${latest.release.version}-shardingsphere-agent-bin.tar.gz -C agent
    2. cd agent
    3. tree
    4. ├── LICENSE
    5. ├── NOTICE
    6. └── agent.yaml
    7. ├── plugins
    8. ├── lib
    9. ├── shardingsphere-agent-metrics-core-${latest.release.version}.jar
    10. └── shardingsphere-agent-plugin-core-${latest.release.version}.jar
    11. ├── logging
    12. └── shardingsphere-agent-logging-file-${latest.release.version}.jar
    13. ├── metrics
    14. └── tracing
    15. ├── shardingsphere-agent-tracing-opentelemetry-${latest.release.version}.jar
    16. └── shardingsphere-agent-tracing-opentracing-${latest.release.version}.jar
    17. └── shardingsphere-agent-${latest.release.version}.jar

    Agent log output location is agent/logs/stdout.log.

    Plugin description

    File

    Currently, the File plugin only outputs the time-consuming log output of building metadata, and has no other log output for the time being.

    Prometheus

    Used for exposure monitoring metrics.

    • Parameter description

    OpenTelemetry

    OpenTelemetry can export tracing data to Jaeger, Zipkin.

    • Parameter description
    • Edit the startup script

    Configure the absolute path of shardingsphere-agent-${latest.release.version}.jar to the start.sh startup script of shardingsphere proxy.

    1. nohup java ${JAVA_OPTS} ${JAVA_MEM_OPTS} \
    2. -javaagent:/xxxxx/agent/shardingsphere-agent-${latest.release.version}.jar \
    • Start ShardingSphere-Proxy

    After startup, you can find the plugin info in the log of ShardingSphere-Proxy, Metric and Tracing data can be viewed through the configured monitoring address.

    Use via container environment

    • Assume that the following corresponding configurations have been completed locally.

      • Folder ./custom/agent/ that contains all files after unpacking ShardingSphere-Agent binary package
      • The folder containing the configuration files of ShardingSphere-Proxy such as server.yaml is ./custom/conf/
    • At this point, the use of ShardingSphere-Agent can be configured through the environment variable . Taking starting in the Docker Compose environment as an example, a reasonable docker-compose.yml example is as follows.
    1. version: "3.8"
    2. services:
    3. apache-shardingsphere-proxy:
    4. image: apache/shardingsphere-proxy:latest
    5. environment:
    6. JVM_OPTS: "-javaagent:/agent/shardingsphere-agent-${latest.release.version}.jar"
    7. PORT: 3308
    8. volumes:
    9. - ./custom/agent:/agent/
    10. - ./custom/conf:/opt/shardingsphere-proxy/conf/
    11. ports:
    12. - "13308:3308"