diff --git a/.changeset/funny-fireants-shop.md b/.changeset/funny-fireants-shop.md new file mode 100644 index 0000000000..762262a60b --- /dev/null +++ b/.changeset/funny-fireants-shop.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-newrelic-dashboard': patch +--- + +- Fix bug where the default time window/snapshot duration was supposed to be 30 days, but ended up being 43 weeks +- Add the optional entity metadata annotation to change the time window of the data shown in the snapshot diff --git a/plugins/newrelic-dashboard/CHANGELOG.md b/plugins/newrelic-dashboard/CHANGELOG.md index ea33fd1444..a5af58354c 100644 --- a/plugins/newrelic-dashboard/CHANGELOG.md +++ b/plugins/newrelic-dashboard/CHANGELOG.md @@ -1,5 +1,12 @@ # @backstage/plugin-newrelic-dashboard +## 0.1.16 + +### Patch Changes + +- Fix bug where the default time window/snapshot duration was supposed to be 30 days, but ended up being 43 weeks +- Add the optional entity metadata annotation to change the time window of the data shown in the snapshot + ## 0.1.15-next.1 ### Patch Changes diff --git a/plugins/newrelic-dashboard/README.md b/plugins/newrelic-dashboard/README.md index a31042b3fe..0c1b62208a 100644 --- a/plugins/newrelic-dashboard/README.md +++ b/plugins/newrelic-dashboard/README.md @@ -60,20 +60,24 @@ const overviewContent = ( ``` -4. Add `newrelic.com/dashboard-guid` annotation in catalog descriptor file +4. Add annotations in catalog descriptor file -To Obtain the dashboard's GUID: Click the info icon by the dashboard's name to access the See metadata and manage tags modal and see the dashboard's GUID. + 1. `newrelic.com/dashboard-guid` + - To obtain the dashboard's GUID: Click the info icon by the dashboard's name to access the See metadata and manage tags modal and see the dashboard's GUID. + 1. `newrelic.com/dashboard-time-window` (optional) + - The time window of information of the data to show in the snapshot in milliseconds. If not included the time window will default to 30 days -``` -// catalog-info.yaml -apiVersion: backstage.io/v1alpha1 -kind: Component -metadata: - # ... - annotations: - newrelic.com/dashboard-guid: -spec: - type: service -``` + ``` + // catalog-info.yaml + apiVersion: backstage.io/v1alpha1 + kind: Component + metadata: + # ... + annotations: + newrelic.com/dashboard-guid: + newrelic.com/dashboard-time-window: # optional + spec: + type: service + ``` All set , you will be able to see the plugin in action! diff --git a/plugins/newrelic-dashboard/package.json b/plugins/newrelic-dashboard/package.json index b488db090c..6da0c4e25e 100644 --- a/plugins/newrelic-dashboard/package.json +++ b/plugins/newrelic-dashboard/package.json @@ -1,6 +1,6 @@ { "name": "@backstage/plugin-newrelic-dashboard", - "version": "0.1.15-next.1", + "version": "0.1.16", "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", diff --git a/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardSnapshotList/DashboardSnapshotList.tsx b/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardSnapshotList/DashboardSnapshotList.tsx index 87f2334bf7..0b7a5830ce 100644 --- a/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardSnapshotList/DashboardSnapshotList.tsx +++ b/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardSnapshotList/DashboardSnapshotList.tsx @@ -52,6 +52,7 @@ function a11yProps(index: number) { } type Props = { guid: string; + duration: number; }; const useStyles = makeStyles( theme => ({ @@ -79,7 +80,7 @@ const useStyles = makeStyles( }), { name: 'DashboardHeaderTabs' }, ); -export const DashboardSnapshotList = ({ guid }: Props) => { +export const DashboardSnapshotList = ({ duration, guid }: Props) => { const styles = useStyles(); const newRelicDashboardAPI = useApi(newRelicDashboardApiRef); const { value, loading, error } = useAsync(async (): Promise< @@ -137,7 +138,7 @@ export const DashboardSnapshotList = ({ guid }: Props) => { name={Entity.name} permalink={Entity.permalink} guid={Entity.guid} - duration={26297430000} + duration={duration ? duration : 2592000000} /> ); diff --git a/plugins/newrelic-dashboard/src/components/NewRelicDashboard/NewRelicDashboard.tsx b/plugins/newrelic-dashboard/src/components/NewRelicDashboard/NewRelicDashboard.tsx index c9cc9bf611..024bd28f00 100644 --- a/plugins/newrelic-dashboard/src/components/NewRelicDashboard/NewRelicDashboard.tsx +++ b/plugins/newrelic-dashboard/src/components/NewRelicDashboard/NewRelicDashboard.tsx @@ -19,7 +19,10 @@ import { Page, Content } from '@backstage/core-components'; import { DashboardEntityList } from './DashboardEntityList'; import { DashboardSnapshotList } from './DashboardSnapshotList'; import { useEntity } from '@backstage/plugin-catalog-react'; -import { NEWRELIC_GUID_ANNOTATION } from '../../constants'; +import { + NEWRELIC_TIME_WINDOW_ANNOTATION, + NEWRELIC_GUID_ANNOTATION, +} from '../../constants'; export const NewRelicDashboard = () => { const { entity } = useEntity(); @@ -35,6 +38,9 @@ export const NewRelicDashboard = () => { guid={String( entity.metadata.annotations?.[NEWRELIC_GUID_ANNOTATION], )} + duration={Number( + entity.metadata.annotations?.[NEWRELIC_TIME_WINDOW_ANNOTATION], + )} /> diff --git a/plugins/newrelic-dashboard/src/constants.ts b/plugins/newrelic-dashboard/src/constants.ts index dd0dcff2d8..a87c41b37c 100644 --- a/plugins/newrelic-dashboard/src/constants.ts +++ b/plugins/newrelic-dashboard/src/constants.ts @@ -14,3 +14,5 @@ * limitations under the License. */ export const NEWRELIC_GUID_ANNOTATION = 'newrelic.com/dashboard-guid'; +export const NEWRELIC_TIME_WINDOW_ANNOTATION = + 'newrelic.com/dashboard-time-window';