AWS recently launched a new integration between Amazon Managed Blockchain and Amazon CloudWatch. You can now benefit from detailed logs showing important activity in your blockchain networks, including activity in your member certificate authority (CA), Hyperledger Fabric peer nodes, and chaincode.
This post shows how to use these new features to track blockchain activity in your decentralized apps. It also discusses how to create alarms in Amazon CloudWatch to notify you of blockchain activity.
Enabling logging in Amazon Managed Blockchain
Before you get started, set up your blockchain network and Fabric client with logging enabled in Amazon CloudWatch Logs. For more information, see Monitoring Blockchain Activity Using CloudWatch Logs.
There are two places where you can enable logging. When you add a member to a blockchain network, you now have the option to enable logging on the member’s certificate authority (CA) service. See the following screenshot.
Enabling any of the logging options creates a log group named
/aws/managedblockchain/<NetworkID>/<MemberID>. If you enable CA logging, you see a log stream under this group called
ca. This log stream contains detailed logs of all activity related to the CA.
You can also enable logging when you create a peer node. You have the option to enable detailed logs that show all activity on the node (peer node logs) or logs created by your chaincode. See the following screenshot.
Chaincode logs can help you track important activity in your business workflows. The CA and peer node logs can help you troubleshoot complex interactions between Fabric components to get insights into your particular workloads.
Adding log messages to chaincode
The chaincode logs feature can be especially useful for tracking important activity in your business workflows. This post demonstrates how to use logs to verify that only users with the appropriate permissions can run chaincode invocations and to raise alerts when a user attempts unauthorized…