# @bestsellerit/backstage-plugin-gkeusage-backend

> Welcome to the gkeusage backend plugin!

Latest version **0.3.2** (published 2022-07-25) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @bestsellerit/backstage-plugin-gkeusage-backend
pnpm add @bestsellerit/backstage-plugin-gkeusage-backend
yarn add @bestsellerit/backstage-plugin-gkeusage-backend
bun add @bestsellerit/backstage-plugin-gkeusage-backend
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2022-07-25 |
| First published | 2021-06-14 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 26.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | wrighbr, gaardsholt, pbrondum, andrei-predoiu |

## Links

- npm: https://www.npmjs.com/package/@bestsellerit/backstage-plugin-gkeusage-backend
- Repository: https://github.com/BESTSELLER/backstage-plugin-gkeusage-backend
- npm.io page: https://npm.io/package/@bestsellerit/backstage-plugin-gkeusage-backend

## Dependencies (9)

- [yn](https://npm.io/package/yn.md) ^5.0.0
- [express](https://npm.io/package/express.md) ^4.17.3
- [winston](https://npm.io/package/winston.md) ^3.6.0
- [node-fetch](https://npm.io/package/node-fetch.md) ^3.2.6
- [@types/express](https://npm.io/package/@types/express.md) *
- [@backstage/config](https://npm.io/package/@backstage/config.md) ^1.0.1
- [@google-cloud/bigquery](https://npm.io/package/@google-cloud/bigquery.md) ^6.0.0
- [express-promise-router](https://npm.io/package/express-promise-router.md) ^4.1.1
- [@backstage/backend-common](https://npm.io/package/@backstage/backend-common.md) ^0.14.1

## Recent versions

- 0.3.2 (latest) — 2022-07-25
- 0.3.1 — 2022-06-10
- 0.3.0 — 2022-04-01
- 0.2.0 — 2022-03-16
- 0.1.2 — 2021-12-14
- 0.1.1 — 2021-08-10
- 0.1.0 — 2021-06-14

## README

# GKE Usage backend

Welcome to the gkeusage backend plugin!


## Setup & Configuration
This plugin must be explicitly added to a Backstage app, along with it's peer frontend plugin.

The plugin requires configuration in the Backstage app-config.yaml to connect googles bigquery API.

```yaml
gkeUsage:
  billingTable: billingProjectId.billingDataSetId.billingTableId
  jobprojectId: ${GOOGLE_PROJECT_ID} # Optional, if set Bigquery job will be executed on this Google project instead of Dataset project.
  google_application_credentials:
    $env: GOOGLE_APPLICATION_CREDENTIALS

```

In addition, configuration of an entity's catalog-info.yaml helps identify which specific cost of  a service/app within GPC this should be presented on a specific entity catalog page.


## Installation

```
# From your Backstage root directory
cd packages/backend
yarn add @bestseller/backstage-plugin-gkeusage-backend
```

Create a new file named `packages/backend/src/plugins/gkeusage.ts`, and add the following to it

```
import { createRouter } from '@bestsellerit/backstage-plugin-gkeusage-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';

export default async function createPlugin({
  logger,
  config,
}: PluginEnvironment): Promise<Router> {
  return await createRouter({ logger, config });
}
```

And finally, wire this into the overall backend router. Edit `packages/backend/src/index.ts`

```
import gkeusage from './plugins/gkeusage';
// ...
async function main() {
  // ...
  const gkeusageEnv = useHotMemoize(module, () => createEnv('gkeusage'));
  apiRouter.use('/gkeusage', await carmen(gkeusageEnv));

```

After you start the backend (e.g. using `yarn start-backend` from the repo root), you should be able to fetch data from it.

# Note the extra /api here
curl localhost:7000/api/gkeusage/health
This should return {"status":"ok"} like before. Success!

---
_Source: https://npm.io/package/@bestsellerit/backstage-plugin-gkeusage-backend · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
