Observability

    Output directory: shardingsphere-agent/shardingsphere-agent-distribution/target/apache-shardingsphere-${latest.release.version}-shardingsphere-agent-bin.tar.gz

    • 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. .
    5. └── apache-shardingsphere-${latest.release.version}-shardingsphere-agent-bin
    6. ├── LICENSE
    7. ├── NOTICE
    8. ├── conf
    9. └── logback.xml
    10. ├── plugins
    11. ├── shardingsphere-agent-logging-base-${latest.release.version}.jar
    12. ├── shardingsphere-agent-metrics-prometheus-${latest.release.version}.jar
    13. ├── shardingsphere-agent-tracing-opentelemetry-${latest.release.version}.jar
    14. ├── shardingsphere-agent-tracing-opentracing-${latest.release.version}.jar
    15. └── shardingsphere-agent-tracing-zipkin-${latest.release.version}.jar
    16. └── shardingsphere-agent.jar
    • Configuration file
    • Parameter description:
    • Edit the startup script

    Configure the absolute path of shardingsphere-agent.jar to the start.sh startup script of shardingsphere proxy.

    1. nohup java ${JAVA_OPTS} ${JAVA_MEM_OPTS} \
    2. -javaagent:/xxxxx/agent/shardingsphere-agent.jar \
    3. -classpath ${CLASS_PATH} ${MAIN_CLASS} >> ${STDOUT_FILE} 2>&1 &
    • Start ShardingSphere-Proxy

    Use via container environment

    • 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.jar"
    7. PORT: 3308
    8. volumes:
    9. - ./custom/agent:/agent/
    10. - ./custom/conf:/opt/shardingsphere-proxy/conf/
    11. ports:
    nametypedescription
    proxy_request_totalCOUNTERproxy request total
    proxy_connection_totalGAUGEproxy connection total
    proxy_execute_latency_millisHISTOGRAMproxy executor latency millis
    proxy_execute_error_totalCOUNTERproxy executor error total
    route_sql_select_totalCOUNTERproxy executor route select sql total
    route_sql_insert_totalCOUNTERproxy executor route insert sql total
    route_sql_update_totalCOUNTERproxy executor route update sql total
    route_sql_delete_totalCOUNTERproxy executor route delete sql total
    route_datasource_totalCOUNTERnumber of datasource routed
    route_table_totalCOUNTERnumber of table routed
    proxy_transaction_commit_totalCOUNTERtransaction commit count total
    proxy_transaction_rollback_totalCOUNTERtransaction rollback count total
    parse_sql_dml_insert_totalCOUNTERproxy executor parse insert sql total
    parse_sql_dml_delete_totalCOUNTERproxy executor parse delete sql total
    parse_sql_dml_update_totalCOUNTERproxy executor parse update sql total
    parse_sql_dml_select_totalCOUNTERproxy executor parse select sql total
    parse_sql_ddl_totalCOUNTERproxy executor parse ddl sql total
    parse_sql_dcl_totalCOUNTERproxy executor parse dcl sql total
    parse_sql_dal_totalCOUNTERproxy executor parse dal sql total
    parse_sql_tcl_totalCOUNTERproxy executor parse tcl sql total
    parse_dist_sql_rql_totalCOUNTERproxy executor parse rql sql total
    parse_dist_sql_rdl_totalCOUNTERproxy executor parse rdl sql total
    parse_dist_sql_ral_totalCOUNTERproxy executor parse ral sql total
    build_infoGAUGEbuild information
    proxy_infoGAUGEproxy information, state:1 OK, state:2 CIRCUIT BREAK
    meta_data_infoGAUGEmeta data information, schema_count:logic number of databases, database_count:actual number of databases