Note: Requires Sparta 0.9.2 or later
This is a multiple CloudFormation-stack Sparta-based application that includes provisioning a Grafana host running on a single EC2 instance.
The Grafana service is provisioned via a WorkflowHook that defines and provisions a separate CloudFormation stack. The GrafanaStack exports the EC2 hostname's PublicDNS name which is then referenced by the HelloWorld
lambda' function's metadata. This binding ensures that the GrafanaStack cannot be deleted until the referring Sparta application (SpartaGrafanaPublisher) is deleted.
The SpartaGrafanaPublisher discovers the PublicDNSName
during init()
by querying CloudFormation:
awsSession := session.New()
cloudFormationSvc := cloudformation.New(awsSession)
params := &cloudformation.DescribeStacksInput{
StackName: aws.String(GrafanaStackName),
}
outputResults, outputResultsErr := cloudFormationSvc.DescribeStacks(params)
Once the DNSName is determined, the SpartaGrafanaPublisher service creates an Influx DB Client to publish go-metrics to the Grafana instance.
To view the single automatically-generated Grafana dashboard, login to the Grafana host (see the GrafanaStack CloudFormation Outputs fror the domain) using admin/admin
and navigate to the Sparta Hello World
dashboard. By default, the HelloWorld.count
counter is tracked, which is the number of lambda reported invocations.
To view the dashboard in action, navigate to the AWS Lambda Console and "Test" the function to begin publishing metrics.