Polaris Quickstart
To quickly get started with Polaris, you'll need to:
- Install the Polaris JavaScript SDK.
- Optionally, install the Polaris framework integration (Angular and React).
- Create a Polaris account.
- Create an application in Polaris.
- Copy the application's API key into your application.
- Connect your application to Polaris.
- Create a Service Level Indicator (SLI or often just referred to as an indicator) for your application.
- Create a Service Level Objective (SLO or often just referred to an an objective) for the indicator and your application.
Install the Polaris JavaScript SDK
The Polaris JavaScript SDK is a small library (7kb gzipped) that you will use to send data to Polaris.
npx @getpolaris.ai/install
Optionally, install the Polaris framework integration
Polaris is framework-agnostic
The Polaris JavaScript SDK is framework-agnostic. For an easier integration path we do provide additional helpers for integrating with React and Angular applications.
You can learn more about these framework-specific integrations at:
Create a Polaris account
Because Polaris is still in a closed beta, you cannot publicly sign up for an account.
But, don't fret! We'd love to help you with your site reliability journey.
Please reach out to us.
Create an application in Polaris
Once you have an account, you can create an application in Polaris. An application is associated with an organization. Your account can be associated with one or more organizations (like GitHub).
To create an application, navigate to an organization and click the Create Application button.
Copy the application API Key
Once you've created an application, you'll need to copy the API key. This is your unique identifier for your application. We'll use this when we configure the Polaris JavaScript SDK.
Connect your application to Polaris
Next, connect your application to Polaris.
import { createConnection } from '@getpolaris.ai/sdk';
createConnection({ apiKey: API_KEY }).catch(console.error);
Now, verify that the connection was successful by checking the console. If there is an error connecting to Polaris you will see an error message in the console. If there is not an error, then you're good to go! 🎉
Create an indicator
An indicator is a metric that you want to track. For example, you might want to track the success/failure rate of an API request. Or, you might want to track core web vitals for your web application.
Instant Core Web Vitals
Note: Core web vitals measurements are automatically sent to Polaris once you connect your application to Polaris.
To create an indicator, navigate to the application you created and click the Create Indicator button.
Let's create an indicator for the Largest Contentful Paint (LCP) core web vital metric.
- First, create a new Indicator in Polaris.
- Specify a name for the indicator. In this example, I'll use "Largest Contentful Paint".
- Specify the indicator window. In this example, I'll use a 5-minute window.
- Specify the indicator operation. In this example, as I want to create an indicator for the Largest Contentful Paint core web vital metric, I'll choose the average operation.
- Finally, we set the predicate function as follows.
function (measurement) {
return measurement.eventName === 'lcp';
}
The predicate function above will filter all measurements with the eventName
of lcp
.
Create an objective
An objective is a target for an indicator. For example, you might want to set a target for the Largest Contentful Paint (LCP) core web vital metric. You might want to set a target that the LCP should be less than 2.5 seconds.
To create an objective, navigate to the application you created and click the Create Objective button.
Let's create an objective for the Largest Contentful Paint (LCP) core web vital metric.
- First, create a new Objective in Polaris.
- Select the "Largest Contentful Paint" indicator we just created.
- Choose the Lower Threshold and set the value to 2500. This will create an objective where the average LCP is less than or equal to 2.5 seconds.
- Finally, we choose a percentile. In this example, I'll choose the 95th percentile.
Webhooks
Next, we'll want to set a webhook URL for our application so that we can receive notifications when our objective is violated.
Navigate to the application you created and modify the Settings for your application. Then, click the Add Webhook button. Enter a URL and click Save Application.
Learn more about how webhooks work in Polaris.
What's next?
Congrats - you've successfully created an application, connected it to Polaris, created an indicator, and created an objective. 🎉