Skip to content

Commit

Permalink
Merge branch 'master' into cayla/clear-search
Browse files Browse the repository at this point in the history
  • Loading branch information
caylahamann authored Jun 25, 2020
2 parents de40df6 + ad2541a commit 0e20507
Show file tree
Hide file tree
Showing 26 changed files with 1,244 additions and 94 deletions.
6 changes: 6 additions & 0 deletions src/components/FeatherIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,16 @@ const ICONS = {
<polyline points="16 16 12 12 8 16" />
</>
),

x: (
<>
<line x1="18" y1="6" x2="6" y2="18" />
<line x1="6" y1="6" x2="18" y2="18" />
),
award: (
<>
<circle cx="12" cy="8" r="7" />
<polyline points="8.21 13.89 7 23 12 20 17 23 15.79 13.88" />
</>
),
};
Expand Down
1 change: 1 addition & 0 deletions src/components/IconReference.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
position: absolute;
font-size: 0.85rem;
top: calc(100% + 0.5rem);
right: 0;
z-index: 1;
}
54 changes: 41 additions & 13 deletions src/components/NavigationItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ import { BreadcrumbContext } from './BreadcrumbContext';
import styles from './NavigationItems.module.scss';
import { link } from '../types';

const iconLibrary = {
'Collect data': 'collectData',
'Build apps': 'buildApps',
'Automate workflows': 'automation',
'Explore docs': 'developerDocs',
};

const featherIconLibrary = {
'Developer champions': 'award',
};

const getHighlightedText = (text, highlight) => {
const parts = text.split(new RegExp(`(${highlight})`, 'gi'));
return (
Expand Down Expand Up @@ -59,6 +70,28 @@ const NavigationItems = ({
});
};

const NavIcon = ({ page }) => {
if (featherIconLibrary[page.displayName]) {
return (
<FeatherIcon
className={styles.headerIcon}
name={featherIconLibrary[page.displayName]}
/>
);
}

if (iconLibrary[page.displayName]) {
return (
<NewRelicIcon
className={styles.headerIcon}
name={iconLibrary[page.displayName]}
/>
);
}

return null;
};

const NavItem = ({ page, depthLevel, searchTerm, filteredPageNames }) => {
const crumbs = useContext(BreadcrumbContext).flatMap((x) => x.displayName);
const isHomePage = crumbs.length === 0 && depthLevel === 0;
Expand All @@ -67,19 +100,8 @@ const NavItem = ({ page, depthLevel, searchTerm, filteredPageNames }) => {
isHomePage || crumbs.includes(page.displayName)
);

const iconLibrary = {
'Collect data': 'collectData',
'Build apps': 'buildApps',
'Automate workflows': 'automation',
'Explore docs': 'developerDocs',
};
const isCurrentPage = crumbs[crumbs.length - 1] === page.displayName;
const headerIcon = depthLevel === 0 && (
<NewRelicIcon
className={styles.headerIcon}
name={iconLibrary[page.displayName]}
/>
);
const headerIcon = depthLevel === 0 && <NavIcon page={page} />;
const display = filteredPageNames
? getHighlightedText(page.displayName, searchTerm)
: page.displayName;
Expand All @@ -104,7 +126,7 @@ const NavItem = ({ page, depthLevel, searchTerm, filteredPageNames }) => {
)}
to={page.url}
>
<span>
<span className={styles.navLinkText}>
{headerIcon}
{display}
</span>
Expand Down Expand Up @@ -154,6 +176,12 @@ const NavItem = ({ page, depthLevel, searchTerm, filteredPageNames }) => {
);
};

NavIcon.propTypes = {
page: PropTypes.shape({
displayName: PropTypes.string.isRequired,
}),
};

NavigationItems.propTypes = {
pages: PropTypes.array.isRequired,
filteredPageNames: PropTypes.array,
Expand Down
5 changes: 5 additions & 0 deletions src/components/NavigationItems.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ button.navLink {
}
}

.navLinkText {
display: flex;
align-items: center;
}

.currentPageIndicator {
stroke-width: 4;
}
Expand Down
Binary file added src/images/nrone-table-guide/added-table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/nrone-table-guide/app-overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/nrone-table-guide/clicked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/nrone-table-guide/demo-app-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/nrone-table-guide/hovered.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/nrone-table-guide/newtable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/nrone-table-guide/nrone-launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/nrone-table-guide/predefined.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/nrone-table-guide/table-new-cells.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/time-picker-guide/add-timepicker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/time-picker-guide/console.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
162 changes: 162 additions & 0 deletions src/markdown-pages/5-min-tag-resources.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
---
path: '/guides/5-min-tag-resources'
duration: '5 min'
title: 'Quickly tag a set of resources'
template: 'GuideTemplate'
description: 'Add tags to applications you instrument for easier filtering and organization.'
---

<Intro>

[Tags](https://docs.newrelic.com/docs/new-relic-one/use-new-relic-one/core-concepts/tagging-use-tags-organize-group-what-you-monitor) help you group, search, filter, and focus the data about your [entities](https://docs.newrelic.com/docs/new-relic-one/use-new-relic-one/core-concepts/what-entity-new-relic), which can be anything from applications to hosts to services. Tagging entities using the New Relic CLI is a good candidate for automation.

In this 5-minute guide, you are going to use the New Relic CLI to add multiple tags to one of your entities.

</Intro>

## Before you begin

For this guide you need your New Relic [personal API Key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#personal-api-key): Create it at the **Account settings** screen of your New Relic account.

<Steps>
<Step>

## Install the New Relic CLI

You can download the New Relic CLI via [Homebrew](https://brew.sh/) (macOS), [Scoop](https://scoop.sh/) (Windows), and [Snapcraft](https://snapcraft.io/) (Linux). You can also download [pre-built binaries](https://github.com/newrelic/newrelic-cli/releases) for all platforms, including .deb and .rpm packages, and our Windows x64 .msi installer.

* #### Linux

With [Snapcraft](https://snapcraft.io/) installed, run:

`sudo snap install newrelic-cli`

* #### macOS

With [Homebrew](https://brew.sh/) installed, run:

`brew install newrelic-cli`

* #### Windows

With [Scoop](https://scoop.sh/) installed, run:

`scoop bucket add newrelic-cli https://github.com/newrelic/newrelic-cli.git`<br />
`scoop install newrelic-cli`

</Step><Step>

## Create your New Relic CLI profile

New Relic CLI profiles contain credentials and settings that you can apply to any CLI command.

To create your first CLI profile, run the [`profiles add`](https://github.com/newrelic/newrelic-cli/blob/master/docs/cli/newrelic_profile_add.md) command. Don't forget to set the [region](https://docs.newrelic.com/docs/using-new-relic/welcome-new-relic/get-started/our-eu-us-region-data-centers) of your New Relic account: use `-r` to set either `us` or `eu` (this is required).

```bash lineNumbers=false
# Create the tutorial account for the US region
newrelic profiles add -n tutorial --apiKey API_KEY -r us
# Set the profile as default
newrelic profiles default -n tutorial
```

</Step><Step>

## Search for an entity

Your New Relic account may have hundreds of entities: Have a quick look by opening the [Entity explorer](https://docs.newrelic.com/docs/new-relic-one/use-new-relic-one/ui-data/new-relic-one-entity-explorer-view-performance-across-apps-services-hosts).

In the terminal, run [`entity search`](https://github.com/newrelic/newrelic-cli/blob/master/docs/cli/newrelic_entity_search.md) to retrieve a list of entities from your account as JSON. In the example, you're searching for all entities with "test" in their name.

```bash lineNumbers=false
# Change the `name` to match any of your existing entities
newrelic entity search --name "test"
```

</Step><Step>

If there are matching entities in your account, the query yields data in JSON format, similar to this workload example.

Select an entity from the results and look for its `guid` value; the `guid` is the unique identifier of the entity. Write it down.

```json lineNumbers=false copy=false
{
"accountId": 123456789,
"domain": "NR1",
"entityType": "WORKLOAD_ENTITY",
"guid": "F7B7AE59FDED4204B846FB08423DB18E",
"name": "Test workload",
"reporting": true,
"type": "WORKLOAD"
},
```
</Step><Step>

## Add tags and tag lists to your entity

With your entity `guid`, you can add tags right away. You can do so by invoking the [`entities tags create`](https://github.com/newrelic/newrelic-cli/blob/master/docs/cli/newrelic_entity_tags_create.md) command.

What if you want to add multiple tags? You can use tag sets for that: While tags are key-value pairs separated by colons, tag sets are comma-separated lists of tags. For example:

`tag1:value1,tag2:value2`

<Important>Adding tags is an asynchronous operation: it could take a little while for the tags to get created.</Important>

```bash lineNumbers=false
# Adding a single tag
newrelic entity tags create --guid GUID --tag key:value
# Adding multiple tags
newrelic entity tags create --guid GUID --tag tag1:test,tag2:test
```
</Step><Step>

## Check that the tags are there

To make sure that the tags have been added to your entities, retrieve them using the [`entity tags get`](https://github.com/newrelic/newrelic-cli/blob/master/docs/cli/newrelic_entity_tags_get.md) command. All tags associated with your entity are retrieved as a JSON array.

`newrelic entity tags get --guid GUID`

<Tip>

Tags can be deleted at any time by invoking the [`entity tags delete`](https://github.com/newrelic/newrelic-cli/blob/master/docs/cli/newrelic_entity_tags_delete.md) command followed by the same arguments you used to create them.

</Tip>


```json lineNumbers=false
[
{
"Key": "tag1",
"Values": [
"true"
]
},
{
"Key": "tag2",
"Values": [
"test"
]
},
{
"Key": "tag3",
"Values": [
"testing"
]
}
// ...
]
```
</Step></Steps>

## Next steps

Have a look at [all the New Relic CLI commands](https://github.com/newrelic/newrelic-cli/blob/master/docs/cli/newrelic.md). For example, you could create a [New Relic workflow](https://docs.newrelic.com/docs/new-relic-one/use-new-relic-one/core-concepts/new-relic-one-workloads-isolate-resolve-incidents-faster) using [`workload create`](https://github.com/newrelic/newrelic-cli/blob/master/docs/cli/newrelic_workload_create.md).

If you'd like to engage with other community members, visit our [New Relic Explorers Hub](https://discuss.newrelic.com/c/build-on-new-relic/developer-toolkit) page. We welcome feature requests or bug reports on [GitHub](https://github.com/newrelic/newrelic-cli).

## Related info

- [Understanding Entity Explorer (Video)](https://www.youtube.com/watch?v=IGZQup8ZEmE)
- [Tagging: Use tags to organize and group what you monitor](https://docs.newrelic.com/docs/new-relic-one/use-new-relic-one/core-concepts/tagging-use-tags-organize-group-what-you-monitor)
- [New Relic CLI commands reference](https://github.com/newrelic/newrelic-cli/blob/master/docs/cli/newrelic.md)
- [New Relic CLI repository on GitHub](https://github.com/newrelic/newrelic-cli)

Loading

0 comments on commit 0e20507

Please sign in to comment.