There are many ways in which the activities and operations performed in Alfresco Content Services can be measured and montiored. In this post, we are going to take a look at montioring Alfresco using monitoring systems such as Prometheus & Grafana. Alfresco repository now exposes an endpoint /alfresco/s/prometheus that is compatible with the Prometheus scarping end point. Data such as JVM Metrics, Database metrics & REST API metrics are currently captured and exposed using the above mentioned endpoint. Prometheus data source can be integrated with the Grafana application where the Alfresco real time activities can be viewed and monitored in a more user-friendly manner.
Configure/Enable Prometheus endpoint metrics in ACS
Though the Prometheus endpoint is available by default in all ACS6.1.x deployments, in order to enable and capture the metrics following properties must be added in ACS alfresco-global.properties file. By default metrics.enabled is set to false, so accessing the Prometheus endpoint/webscript without these changes will return HTTP 404 error.
Once enabled, accessing the endpoint URL will display JVM metrics, DB metrics & REST API metrics related to Alfresco.
# HELP system_cpu_usage The "recent cpu usage" for the whole system # TYPE system_cpu_usage gauge system_cpu_usage 0.16914462251399884 # HELP jvm_threads_peak The peak live thread count since the Java virtual machine started or peak was reset # TYPE jvm_threads_peak gauge jvm_threads_peak 169.0 # HELP jvm_threads_daemon The current number of live daemon threads # TYPE jvm_threads_daemon gauge jvm_threads_daemon 132.0
In this case I am using Mac, so I used Homebrew to install Prometheus.
brew install prometheus
Before starting up the Prometheus instance, you would need to configure the Alfresco metrics path and the appropriate Target URL (ACS Host URL) in prometheus YAML config file (prometheus.yml). You can get a copy of the default YAML file here - YAML Config
Key properties to note are 1) metrics_path & 2) targets in the scrape_configs section. Update the target property based on your ACS instance.
Save the file and then copy the file to/etc/prometheus directory. Once done run the following command to start Prometheus
Monitor the logs and once the service is started, navigate to http://localhost:9090/config(listens to port 9090 by default). The config page should reflect the metrics_path & targets value that was done earlier.
Start Grafana using brew services start grafana and monitor the startup logs. Navigate to Grafana dashboard on http://localhost:3000/
In order to display and monitor the Alfresco metrics in the Grafana Dashboard, following steps are necessary.
1) Create a Promethues data source by clicking on the "Create your first data source" link in the home page. Select Prometheus and Enter http://localhost:9090 in the URL field. If "Basic Authenticaton" is selected, uncheck it and save the data source.
2) Create/Import dashboards to Grafana app and monitor the real-time metrics in Dashboard view. Sample dashboard JSON files are available in - https://github.com/Alfresco/acs-packaging/tree/master/docs/micrometer. Three different JSON files covering DB Metrics, JVM Metrics & REST API metrics are available in GitHub. While Importing the JSON file make sure the correct Promethues data source is selected.
Once the above steps are done, real-time metrics can be seen and monitored in the Grafana dashboards.