Cloud Hub is a Java library that uses Grafana and helps you monitoring your Multicloud System, providing ready-to-use and configurable Dashboards.
You don't need to have any Grafana files installed on your system. The library is responsible to deploy the Grafana server folder for you and runs it on localhost. The only thing you need to do is to add the Dashboards of the services you want to monitor.
How it works: A compressed folder of a portable Grafana server instance is embedded in the Cloud Hub package. On startup the folder is moved to a temporary directory, decompressed and finally the grafana-server executable is started. When you configure and then add a new Dashboard to a Grafana instance, the library will automatically make the provisioning for you, creating its configuration files and placing them in the server directory.
Currently Cloud Hub is developed on Ubuntu 19.04, but we are planning to support other Operating Systems. It should not be difficult since it's just a matter of resolving OS's dependencies (Grafana binaries files, process management, ...)
OS | Supported |
---|---|
Ubuntu | ✔️ |
Windows | 🔨 |
Mac OS | ✖️ |
This is a list of the currently supported services you can monitor through the library:
Cloud Provider | Service Name |
---|---|
Amazon Web Services | Billing |
EC2 | |
Lambda | |
S3 | |
SQS | |
Microsoft Azure | Functions |
Storage Container | |
Storage Queue | |
VMs |
You can also run a simple HTTP Web Server to monitor the local system (CPU usage and temperature, Memory usage) in real time.
- Zip4j - to manage (essentially extract) the archive containing the Grafana server;
- JSON-java - to better manage the data exchange with Grafana for the Local Monitoring;
- jSensors - to get the CPU temperature.
Thanks to all the creators for their awesome work!
In order to monitor a specific service, you need to get a Grafana instance first specifying the web server port and a flag indicating whether or not to print the console logs:
Grafana grafana = new Grafana(SERVER_PORT, FLAG);
Then specify the appropriate Datasource of the service you want to monitor, e.g. CloudWatch for Amazon Web Services:
CloudWatchDataSource datasource = new CloudWatchDataSource("ACCESS_KEY", "SECRET_KEY", "DEFAULT_REGION");
Now you have to define a Dashboard compatible with the Datasource we created earlier, e.g. AWS Lambda:
AWSLambdaDashboard dashboard = new AWSLambdaDashboard("DASHBOARD_NAME", datasource);
You finally have to add the Dashboard to the Grafana instance in order to effectively deploy its configuration:
grafana.add(dashboard);
NOTE: optionally for this particular Dashboard, in order to hide the rest of the functions listed in the account, you can filter specific Lambda functions using their names in the method:
dashboard.addFunction("FUNCTION_NAME");
either before or after adding the Dashboard to Grafana. If you want to enable the Local Monitoring, you need to specify the port where the server is going to run and the delay that will be applied for collecting local data:
grafana.enableLocalMonitoring(API_PORT, COLLECTOR_DELAY);
- grafana.Grafana
- grafana.datasource
- grafana.dashboard
It's the core of the library as it represents the Grafana server itself and it's used to control the dashboards.
Deploys a new Grafana server instance in a temporary system folder.
httpPort
is the port where the Grafana Web interface will listen onconsoleLog
enable/disable the Grafana console logs
Runs the Grafana server previously deployed.
Adds a dashboard to Grafana by deploying its configuration file.
dashboard
is one of the supported dashboards (which extends the abstract Dashboard class)
Removes a dashboard from Grafana by deleting its configuration file.
dashboard
is one of the supported dashboards (which extends the abstract Dashboard class)
Enables the local monitoring dashboard along with the HTTP API server that provides data to Grafana and the thread that collects the informations about the local resources.
apiPort
is the port of the HTTP API servercollectorDelay
is the time in milliseconds between one measurement and another
Disables the local monitoring by removing its dashboard and stopping the collector thread along with the HTTP API server.
Prevents the Grafana process to close when there are no more instructions left in Java (note that this method is blocking).
Represents the Azure Monitor Datasource and is responsible to create its configuration file for provisioning.
AzureMonitorDataSource(String tenantId, String clientId, String clientSecret, String defaultSubscription, String applicationId, String apiKey)
You need 4 pieces of information from the Azure Portal:
tenantId
(Azure Active Directory -> Properties -> Directory ID)clientId
(Azure Active Directory -> App Registrations -> Choose your app -> Application ID)clientSecret
(Azure Active Directory -> App Registrations -> Choose your app -> Keys)defaultSubscription
(Subscriptions -> Choose subscription -> Overview -> Subscription ID)
You need 2 more pieces of information from the Azure Portal:
applicationId
apiKey
Please refer to this link to know how to get them. If you are still having problems, please refer to the Grafana documentation here.
Represents the CloudWatch Datasource from AWS and is responsible to create its configuration file for provisioning.
Grafana needs permissions granted via IAM to be able to read CloudWatch metrics. So after creating the role needed you have to provide:
accessKey
secretKey
You can find more about that on the Grafana documentation here. If you need a quick guide have a look at this.
You also need to specify:
defaultRegion
(e.g. us-east-1)
Represents the Dashboard used to monitor the AWS Lambda functions.
name
is a unique name used to identify the Dashboard. It is also its title in GrafanacloudWatchDataSource
is the Datasource where to get the informations from
Adds a function to be monitored from the Dashboard.
functionName
is the name of the function you want to monitor
Represents the Dashboard used to monitor the AWS SQS service.
name
is a unique name used to identify the Dashboard. It is also its title in GrafanacloudWatchDataSource
is the Datasource where to get the informations from
Adds a queue to be monitored from the Dashboard.
queueName
is the name of the queue you want to monitor
Represents the Dashboard used to monitor the AWS Billing service.
name
is a unique name used to identify the Dashboard. It is also its title in GrafanacloudWatchDataSource
is the Datasource where to get the informations from
Represents the Dashboard used to monitor the Azure Functions service.
name
is a unique name used to identify the Dashboard. It is also its title in GrafanaazureMonitorDataSource
is the Datasource where to get the informations from
Adds a function to be monitored from the Dashboard.
functionName
is the name of the function you want to monitor
Represents the Dashboard used to monitor the Azure Queue Storage service.
AzureQueueDashboard(String name, String resourceGroup, String resourceName, AzureMonitorDataSource azureMonitorDataSource)
name
is a unique name used to identify the Dashboard. It is also its title in GrafanaresourceGroup
is the name of the resource group where the storage account is locatedresourceName
is the name of the storage accountazureMonitorDataSource
is the Datasource where to get the informations from
The only Azure Monitor limitation is that you can't filter the queue you want to monitor, but you will get all of them together. In order to overcome this limitation there is the Azure Service Bus which is not implemented yet.