This plugin, in combination with the frontend plugin, provides automatic, scheduled export functionality of users, groups, and components from Backstage into OpsLevel.
In the root directory of your Backstage installation, run the following command:
yarn add --cwd packages/backend @opslevel/backstage-maturity-backend
Create a file called opslevel.ts
in the packages/backend/src/plugins
subdirectory of your Backstage installation and insert the following contents:
import { Router } from 'express';
import { PluginEnvironment } from '../types';
import { OpsLevelBuilder } from '@opslevel/backstage-maturity-backend';
export default async function createPlugin(
env: PluginEnvironment,
): Promise<Router> {
const builder = await OpsLevelBuilder.create(env);
const router = await builder.build();
return router;
}
Open the index.ts
file in the packages/backend/src
subdirectory of your Backstage installation with the code editor of your choice.
Add the following line after the end of the existing import statements:
import opslevel from './plugins/opslevel';
Add the following statement to the cluster of similar statements near the top of the main()
function:
const opslevelEnv = useHotMemoize(module, () => createEnv('opslevel'));
Add the following statement to the cluster of similar statements a bit further down in the main()
function:
apiRouter.use('/opslevel', await opslevel(opslevelEnv));
Set up the necessary configuration in your Backstage instance's app-config.yaml
. Note: that this configuration is the same as for installing the installing the frontend plugin, if you've already done the changes in app-config.yaml
for the frontend plugin, you don't need to do this again.
Add a proxy configuration for OpsLevel. Replace <your_OpsLevel_API_token>
with a token from https://app.opslevel.com/api_tokens (or, if you're running a self-hosted OpsLevel instance, the /api_tokens
page on your OpsLevel instance).
proxy:
endpoints:
'/opslevel':
target: 'https://app.opslevel.com'
credentials: 'dangerously-allow-unauthenticated'
headers:
X-Custom-Source: backstage
Authorization: Bearer <your_OpsLevel_API_token>
allowedHeaders: ['GraphQL-Visibility']
If you're running Self-Hosted OpsLevel, replace target
with your URL.
opslevel:
baseUrl: 'https://app.opslevel.com'
If you're running Self-Hosted OpsLevel, replace baseUrl
with your URL.