AppBeat Blog

Perfect Monitoring for Your Cloud

Coming soon: multi expression rules for better monitoring experience

Very soon we will add multi expression support for Warning and Error notification rules. Syntax will be as following:

[trigger_rule: YOUR_RULE_NAME_1]
EXPRESSION(S)_1

[trigger_rule: YOUR_RULE_NAME_2]
EXPRESSION(S)_2

[trigger_rule: YOUR_RULE_NAME_N]
EXPRESSION(S)_N

On user interface this will look something like this:

This example rule then triggers "Warning" notification which is sent to you and it is also visible in monitor log:

 

How to periodically run SSH commands and trigger AppBeat alert

In AppBeat 1.4.5 we introduced support for running SSH commands where you can trigger monitoring alert by checking result of:

  • command exit status code (for example you can simply trigger error if exit status code is not 0)
  • checking specific text in standard output (stdout) by running regex expression
  • checking specific text in standard error (stderr) by running regex expression

You can add new SSH monitor by clicking "Add new periodic monitor", enter monitor name and from "Agent type" select "Run Secure Shell (SSH) command":

On next step enter SSH hostname or server IP address and type command you would like to run (for example script name or cat /proc/uptime, ...) and specify server authentication. You can use standard username/password authentication or key based authentication (with private key in OpenSSH format).

After you finished "New periodic check" wizard we will immediately start monitoring your SSH server by running your command and checking for expected result.

Happy monitoring!

p.s. if you don't have AppBeat account yet, you can create one for free!

How to detect if Azure SQL database is in primary or secondary role?

If you want to have highly available Azure SQL Database it is highly recommended that you configure Active Geo-Replication (this feature is available for all databases in all service tiers).

Active Geo-Replication consists of two (or more) databases in different regions, where one database is primary (read + write operations) and all other databases are secondaries (allowed only read operations). Secondary databases are automatically synced with changes in your primary database.

Failover event can be triggered manually or if disastrous event happens in one of Azure datacenters. In this case your primary database goes into secondary mode and one of your secondaries becomes new primary database. If you are accessing your databases directly by using connection string, you will have to update it to reflect primary / secondary database switch.

Of course, we want to update our connection string automatically and we will show you two C# code snippets how to detect which database is currently primary (in our examples we operate with one primary and one secondary database).

Example 1

Run special query on each database to determine if it is in primary or secondary role:

public static async Task<string> GetPrimaryConnectionString()
{
	bool? isPrimary = await IsPrimaryAsync(YOUR_CONNECTION_STRING_DB1);
	if (isPrimary == true)
	{
		return YOUR_CONNECTION_STRING_DB1;
	}
	
	isPrimary = await IsPrimaryAsync(YOUR_CONNECTION_STRING_DB2);
	if (isPrimary == true)
	{
		return YOUR_CONNECTION_STRING_DB2;
	}
	
	//could not determine which database is primary
	return null;
}

private static async Task<bool?> IsPrimaryAsync(string connectionString)
{
	try
	{
		using (var conn = new SqlConnection(connectionString))
		{
			if (conn.State != System.Data.ConnectionState.Open)
			{
				await conn.OpenAsync();
			}

			using (var cmd = conn.CreateCommand())
			{
				cmd.CommandText = "SELECT role FROM sys.dm_geo_replication_link_status";
				var res = await cmd.ExecuteScalarAsync();
				return Convert.ToInt32(res) == 0;
			}
		}
	}
	catch (Exception ex)
	{
		//handle exception
		return null;
	}
}

Example 2

If you try to update database which is currently in secondary role you will get following SqlException: Failed to update database "YOUR_DB_NAME" because the database is read-only.

You can use this information to update your connection string:

try
{
	//your code
}
catch (SqlException sqlException)
{
	if (IsReadOnlyDatabase(sqlException) == true)
	{
		//current connection string probably points to secondary database (sqlException.Server)
		//update your connection string to your other database
	}
}

private static bool? IsReadOnlyDatabase(SqlException se)
{
	if (se?.Errors == null) return null;

	foreach (SqlError error in se.Errors)
	{
		if (error.Number == 3906)
		{
			return true;
		}
	}

	return false;
}

 

How to send service outage alerts to your Slack channel?

Want to integrate your website monitoring notifications with Slack? Please follow these instructions.

Step 1

From AppBeat dashboard, click on Account in the left navigation and then choose Integrations from tab menu.

Step 2

Press the Slack button which opens Add notification channel dialog. Enter arbitrary name for this channel and your Slack webhook URL.

To make sure that everything works please click Test button which should send test notification to your Slack channel. If you don't receive any message we suggest that you double check your webhook URL. When everything looks OK you can click Add button.

Step 3

Click on Services & Checks in the left navigation and double click on service for which you want to enable Slack notifications. In Edit service dialog, please click on Notification types tab. Enable your slack channel and click Save. You can repeat this step for your other services.

 

Backup web client for high availability

Some of our users are constantly using our "Live status" page by their monitoring teams. Primarily for this reason we are introducing secondary backup web client which can be used to monitor "Live status" page even if there is issue or outage of primary web client. Backup web client is actively running on different datacenter and can be accessed by navigating to web2.appbeat.io (this is also displayed in application footer).

Is this feature available for our free users? Of course, this feature is available for all our users! If you are not yet member, you can register here for free.

We are one of rare monitoring provider to offer such feature to their users!

---

High level diagram of current AppBeat architecture:

Embed service status to your dashboard

Today we published new version of AppBeat (1.3.4) which allows users to enable embeddable status images for each service. You can access this feature from "Public status / Embed Status":

Images are periodically updated with latest statuses by following rules:

  • if there is no status change for your service then image is refreshed every 5 minutes
  • if service status changes (from good to error, from warning to good, etc.) then we try to upload new status image as soon as possible (this is usually less than 30 seconds after you received your notification)

Status images can be embedded to your internal dashboards or internet facing websites. Image URL contains random Globally Unique Identifier (GUID) in its name which allows you too keep links private / for internal use only.

Optionally you can also customize image template with your own colors and texts (for example, you can remove service name from image).

This feature is available only for paid accounts (from 1.99 EUR / month).

AppBeat web app can now run on Linux!

We have successfully migrated our web application from .NET Core RC1 to .NET Core RC2 and published it on test Linux instance (CentOS). Best of all: AppBeat binaries are 100% identical to those on Windows (same cross platform codebase!) and were simply copied to Linux... And it works! It works great!

Here are some setup details for those who are interested.

First, you have to install .NET Core runtime by following simple instructions on Microsoft .NET Core website.

ASP.NET Core web applications are running on lightweight web server called Kestrel, but since it lacks some of important web server features (for example HTTPS, various built-in tools, ...) it is usually configured to run in tandem with other web server of your choice. On Windows this is IIS, on CentOS we selected NGINX. Those web servers then forward your request to Kestrel which runs your ASP.NET Core web application, creates output and returns it back to main web server.

To setup NGINX to forward requests to Kestrel you have to edit nginx.conf with following (adapt if needed):

location / 
{
proxy_pass http://127.0.0.1:5000;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Original-Proto $scheme;
proxy_set_header X-Original-For $remote_addr;
proxy_http_version 1.1;
}

Then we installed supervisor to monitor our Kestrel process and make sure it is always running:
sudo yum install supervisor

We created kestrel_default.ini file in /etc/supervisord.d/kestrel_default.ini with following content:

[program:kestrel_default]
command=dotnet /usr/share/nginx/WebApp/AppBeat.Web.dll
directory=/usr/share/nginx/WebApp
autorestart=true
autostart=true
stdout_logfile=/var/log/AppBeat/app_std_out.log
stderr_logfile=/var/log/AppBeat/app_err.log

After you saved file you can start Kestrel process by typing:

sudo supervisorctl start kestrel_default

Make sure nginx and supervisor are started on system boot:

sudo systemctl enable nginx
sudo systemctl enable supervisord

This is pretty much it :) We are now prepared for future! If you have questions you can reach us on @AppBeatMonitor

Monitor websites with ease

If your technical support is using AppBeat Live status screen to monitor current performance and availability of your systems, we have new useful feature for you.

You can now enable sound alarm which is automatically triggered when "Live status" icon turns red. This additionally minimizes chance for missed alarms (other notifications, such as Slack, PagerDuty, email, SMS are of course also dispatched as configured).

You can enable / disable this feature by clicking bell icon as shown below:

Before relying on this functionality please click "sound test" link to see if your web browser supports Audio API. Most modern browsers should support this feature out of the box. If everything works you should hear test alarm for approximately 15 seconds.

Would you like to see this feature in action? Sign up for free account and try it yourself!

Integration with PagerDuty - The Incident Resolution Platform

Today we published AppBeat 1.3.0 which implements support for third-party notification providers (from Account / Integrations). We are also happy to announce that first provider to be implemented in AppBeat is PagerDuty (available to all users, even those on Free Plan).

You can add PagerDuty to your AppBeat account by following these easy steps:

  • click "Account / Integrations":

  • click on "PagerDuty" button to add new notification channel (you can add multiple PagerDuty notification types; ServiceKey can be obtained on your PagerDuty website):

  • once you have tested and added your PagerDuty notification please click on "Services & Checks". Now double-click on desired service and click "Notification types" tab. Select your PagerDuty notification:

Congratulations! You have successfully integrated your PagerDuty service! From now on, when your service fails, you will automatically receive incident report directly to your PagerDuty!

We will soon add support for more third party incident management tools. Stay tuned!