Skip to content

Commit

Permalink
Merge branch 'Core-users-docs' of https://github.com/newrelic/docs-we…
Browse files Browse the repository at this point in the history
…bsite into Core-users-docs
  • Loading branch information
zuluecho9 committed Nov 11, 2021
2 parents 80ef831 + 4607f3c commit 533a1d7
Show file tree
Hide file tree
Showing 46 changed files with 359 additions and 30 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@github-docs/frontmatter": "^1.3.1",
"@mdx-js/mdx": "^2.0.0-next.8",
"@mdx-js/react": "^2.0.0-next.8",
"@newrelic/gatsby-theme-newrelic": "^3.4.0",
"@newrelic/gatsby-theme-newrelic": "^3.4.2",
"@splitsoftware/splitio-react": "^1.2.4",
"babel-jest": "^26.3.0",
"common-tags": "^1.8.0",
Expand Down Expand Up @@ -152,7 +152,8 @@
"extract-i18n": "i18next",
"get-translated-files": "node scripts/actions/add-files-to-translation-queue.js",
"check-for-outdated-translations": "node scripts/actions/check-for-outdated-translations.js",
"verify-mdx": "node scripts/verify_mdx.js"
"verify-mdx": "node scripts/verify_mdx.js",
"add-remove-redirects": "node scripts/utils/docs-content-tools/add-remove-redirects.js"
},
"husky": {
"hooks": {
Expand Down
72 changes: 72 additions & 0 deletions scripts/utils/docs-content-tools/add-remove-redirects.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const {
getFilePaths,
getUserInputs,
separateData,
joinData,
addRedirect,
removeRedirect,
} = require('./handlers');
const fs = require('fs');

/**
* Process the results from the add/remove redirects and prints them
* @param {Object} results - Object containing either added/skipped/removed redirects
*/
const processResults = (results) => {
const addedRedirects = results.filter((file) => file.added);
const skippedRedirects = results.filter((file) => file.skipped);
const removedRedirects = results.filter((file) => file.removed);

if (addedRedirects.length) {
console.log('(✔️) Added Redirects to the following paths:');
addedRedirects.forEach((filepath) => console.log(` - ${filepath.added}`));
}

if (removedRedirects.length) {
console.log('(✔️) Removed Redirects from the following paths:');
removedRedirects.forEach((filepath) =>
console.log(` - ${filepath.removed}`)
);
}

if (skippedRedirects.length) {
console.log(
'(✔️) The following files either contain no redirects or already contain the slug:'
);
skippedRedirects.forEach((filepath) =>
console.log(` - ${filepath.skipped}`)
);
}
};

const main = async () => {
const { action, directory } = getUserInputs();
const filePaths = getFilePaths(directory);

if (!filePaths.length) {
console.warn(`<!> No .mdx files found in the directory. Please check: ${directory}`);
return;
}

const separatedData = filePaths.map(separateData);

const editedData = separatedData.map((data) => {
if (action === 'add') {
return addRedirect(data);
}
return removeRedirect(data);
});

const joinedData = editedData.map(joinData);

joinedData.forEach(({ data, path }) => {
try {
fs.writeFileSync(path, String(data));
} catch (err) {
console.error(err);
}
});
processResults(editedData);
};

main();
170 changes: 170 additions & 0 deletions scripts/utils/docs-content-tools/handlers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
const glob = require('glob');
const frontmatterGH = require('@github-docs/frontmatter');
const fs = require('fs');

/**
* Adds slashes to beginning and end of directory if missing
* @param {String} directory - The directory to add slashes to
* @returns {String} The directory with slashes added if necessary
*/
const formatDirectory = (directory) => {
if (!directory.startsWith('/')) {
return `/${directory}`;
} else if (!directory.endsWith('/')) {
return directory.concat('/');
}

return directory;
};

/**
* Gets slug from path, relative to contents folder
* @param {String} filepath - The full filepath of the file
* @returns {String} The slug of the filepath
*/
const getSlugFromPath = (filepath) => {
const slug = filepath.match(/content(.*?).mdx/)[1];
if (!slug) {
console.error(
`<!> Could not find slug from path: ${filepath}, please check filepath`
);
process.exit(1);
}
return slug;
};

/**
* Reads a file and separates the content and frontmatter data
* @param {String} path - The full filepath of the file
* @returns {Object} Original path, slug from path, content, frontmatter data
*/
const separateData = (path) => {
const file = fs.readFileSync(path, 'utf8');
const slug = getSlugFromPath(path);
const separateData = frontmatterGH(file);
const { data: frontmatterData, content } = separateData;
if (!frontmatterData.redirects) {
frontmatterData.redirects = [];
}
return { path, content, frontmatterData, slug };
};

/**
* Joins the content and frontmatter data
* @param {Object} data - content, frontmatterData, path
* @returns {Object} Combined data and path
*/
const joinData = ({ content, frontmatterData, path }) => {
const data = frontmatterGH.stringify(content, frontmatterData, {
lineWidth: -1,
});

return { path, data };
};

/**
* Adds a redirect if the slug is not already in the redirects array
* @param {Object} data - slug, frontmatterData, rest
* @returns {Object} Edited frontmatterData, whether the redirect was added or skipped
*/
const addRedirect = ({ frontmatterData, slug, ...rest }) => {
if (frontmatterData.redirects.includes(slug)) {
return { frontmatterData, ...rest, skipped: slug };
}
return {
frontmatterData: {
...frontmatterData,
redirects: [...frontmatterData.redirects, slug],
},
...rest,
added: slug,
};
};

/**
* Removes a redirect if the slug is in the redirects array
* @param {Object} data - slug, frontmatterData, rest
* @returns {Object} Edited frontmatterData, whether the redirect was removed or skipped
*/
const removeRedirect = ({ frontmatterData, slug, ...rest }) => {
if (frontmatterData.redirects.includes(slug)) {
frontmatterData.redirects = frontmatterData.redirects.filter(
(path) => path !== slug
);
if (frontmatterData.redirects.length === 0) {
delete frontmatterData.redirects;
}
return {
frontmatterData,
...rest,
removed: slug,
};
}
return { frontmatterData, ...rest, skipped: slug };
};

/**
* Globs an array of all mdx files in a directory + sub-directories
* @param {String} directory - The parent directory to search
* @returns {String[]} All mdx files in the directory and sub-directories
*/
const getFilePaths = (directory) => {
const subDir = directory.length ? directory : '/docs/';
return glob.sync(`${__dirname}/../../../src/content${subDir}**/*.mdx`);
};

/**
* Retrieves the user inputs from command line
* @returns {Object} The directory and action specified by the user
*/
const getUserInputs = () => {
const userInputs = process.argv.slice(2);
const actionInput = userInputs.find((input) =>
['--add', '--remove'].includes(input)
);

const printExample = () =>
console.warn(
'Example: yarn add-remove-redirects --add src/content/docs/apm'
);

if (!actionInput) {
console.warn(
'<!> No action specified, please append `--add` or `--remove` to the command'
);
printExample();
process.exit(0);
}

const action = actionInput.replace('--', '');

const directoryInput = userInputs.find((input) => input !== actionInput);

if (!directoryInput) {
console.warn(
'<!> No directory specified, please include the directory you want to apply changes to'
);
printExample();
process.exit(0);
}

const formattedDirectory = formatDirectory(directoryInput);
if (!fs.existsSync(`src/content/${formattedDirectory}`)) {
console.warn(
'<!> The directory does not exist, please check the your path. Remember that you should not include the `src/content` portion of the path.'
);
printExample();
process.exit(0);
}

return { action, directory: formattedDirectory };
};

module.exports = {
getFilePaths,
getUserInputs,
separateData,
joinData,
addRedirect,
removeRedirect,
};
4 changes: 2 additions & 2 deletions src/content/docs/apis/intro-apis/new-relic-api-keys.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ You can also [create additional license keys and manage them with our NerdGraph

New Relic user keys, sometimes referred to as "personal API keys", are required for using [NerdGraph](/docs/apis/intro-apis/introduction-new-relic-apis/#graphql) and for the [REST API](/docs/apis/intro-apis/introduction-new-relic-apis/#rest-api).

A user key is tied to both a specific New Relic user and a specific account. Our APIs that use this key let a user make queries for any accounts that user has been granted access to.
A user key is tied to both a specific New Relic user and a specific account, and they cannot be transferred. Our APIs that use this key let a user make queries for any accounts that user has been granted access to, not just the specific account the key was created under. If the key's user is deleted, all their user keys will be deactivated and will no longer be valid in API requests.

To view and manage the user key and other API keys in the UI: From the [account dropdown](/docs/accounts-partnerships/education/getting-started-new-relic/glossary#account-dropdown), click **API keys** ([here's a direct link to the API keys page](https://one.newrelic.com/launcher/api-keys-ui.api-keys-launcher)).

Expand Down Expand Up @@ -155,4 +155,4 @@ To find and manage Insights query keys: From the [account dropdown](/docs/accoun

## Account ID [#account-id]

Looking for the account ID? See [Account ID](/docs/accounts/accounts-billing/account-setup/account-id).
Looking for the account ID? See [Account ID](/docs/accounts/accounts-billing/account-setup/account-id).
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Use the following command:

```
curl -X POST 'https://api.newrelic.com/v2/browser_applications.json' \
-H "X-Api-Key:<var>${APIKEY}</var>" -i
-H "X-Api-Key:<var>${APIKEY}</var>" -i \
-H 'Content-Type: application/json' \
-d \
'{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3912,7 +3912,7 @@ For settings nested in stanzas, prepend the stanza name to the setting name. For
Agent configuration via environment variables requires [Java agent version 4.10.0 or higher](/docs/agents/java-agent/installation/upgrade-java-agent).
</Callout>

For agent versions older than 4.10.0 the following environment variables are available:
For agent versions 4.10.0 or higher the following environment variables are available:

<CollapserGroup>
<Collapser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ redirects:
- /docs/infrastructure/new-relic-infrastructure/troubleshooting/wrong-host-name-reported
---

## Problem
## Problem [#problem]

The agent is working, but the [infrastructure monitoring UI](/docs/infrastructure/new-relic-infrastructure/infrastructure-ui-pages/infrastructure-compute-page-measure-resource-usage) shows the wrong hostname.

## Solution
## Solution [#solution]

To set the correct hostname, try the following steps:

Expand Down Expand Up @@ -69,6 +69,6 @@ To set the correct hostname, try the following steps:
</Collapser>
</CollapserGroup>

## Cause
## Cause [#cause]

The New Relic infrastructure agent tries to resolve its [fully qualified domain name](https://en.wikipedia.org/wiki/Fully_qualified_domain_name) against a domain name server, which may not be properly configured or not controlled by the same user as the New Relic infrastructure agent.
In Linux and macOS, the New Relic infrastructure agent tries to resolve its [fully qualified domain name](https://en.wikipedia.org/wiki/Fully_qualified_domain_name) against a domain name server, which may not be properly configured or not controlled by the same user as the New Relic infrastructure agent. In Windows, it resolves the domain name using internal tools.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Our Kubernetes integration is compatible with the following versions, depending

<tr>
<td>
Kubernetes cluster EKS (EC2 nodes or Fargate)
Kubernetes cluster EKS, EKS-Anywhere, EKS-Fargate
</td>

<td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Before starting our [automated installer](https://one.newrelic.com/launcher/k8s-
<Collapser
className="freq-link"
id="install-amazon-eks"
title={<><img src={eks} alt="EKS" style={{ verticalAlign: 'middle' }}/> <Link to="#install-amazon-eks"> Amazon EKS</Link></>}
title={<><img src={eks} alt="EKS" style={{ verticalAlign: 'middle' }}/> <Link to="#install-amazon-eks"> Amazon EKS / EKS-Anywhere</Link></>}
>
The Kubernetes integration monitors worker nodes. In Amazon EKS, master nodes are managed by Amazon and abstracted from the Kubernetes platforms.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ The New Relic metrics adapter receives the query including the `nginx_average_re
FROM Metric SELECT average(nginx.server.net.requestsPerSecond) WHERE clusterName=<clusterName> AND `k8s.namespaceName`='nginx' SINCE 2 MINUTES AGO
```

Notice that a `clusterName` filter has been automatically added to the query to exclude metrics from other clusters in the same account. You can remove it by using the `removeClusterFilter` configuration parameter. Also the value is cached for a period of time defined by the `cacheTTLSeconds` configuration parameter, whose deafult is 30 seconds.
Notice that a `clusterName` filter has been automatically added to the query to exclude metrics from other clusters in the same account. You can remove it by using the `removeClusterFilter` configuration parameter. Also the value is cached for a period of time defined by the `cacheTTLSeconds` configuration parameter, whose default is 30 seconds.

## Troubleshooting [#troubleshooting]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ Make sure your Android app meets these requirements:

<td>
Android 5.0 or higher

* Version **6.0.0** and higher: Build must be compiled with Android SDK Tools version 21 or higher.
* Version **5.0.0** and higher: Build must be compiled with Android SDK Tools version 14 or higher.
</td>
</tr>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ subject: Mobile app for iOS
releaseDate: '2013-01-29'
version: '1.02'
downloadLink: 'https://itunes.apple.com/us/app/new-relic/id594038638?mt=8'
redirects:
- /docs/release-notes/mobile-apps-release-notes/new-relic-ios-release-notes/new-relic-ios-102
---

### Notes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ subject: Mobile app for iOS
releaseDate: '2013-02-14'
version: '1.1'
downloadLink: 'https://itunes.apple.com/us/app/new-relic/id594038638?mt=8'
redirects:
- /docs/release-notes/mobile-apps-release-notes/new-relic-ios-release-notes/new-relic-ios-11
---

### Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ subject: Mobile app for iOS
releaseDate: '2013-02-27'
version: '1.2'
downloadLink: 'https://itunes.apple.com/us/app/new-relic/id594038638?mt=8'
redirects:
- /docs/release-notes/mobile-apps-release-notes/new-relic-ios-release-notes/new-relic-ios-12
---

### New features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ subject: Mobile app for iOS
releaseDate: '2013-03-14'
version: '1.5'
downloadLink: 'https://itunes.apple.com/us/app/new-relic/id594038638?mt=8'
redirects:
- /docs/release-notes/mobile-apps-release-notes/new-relic-ios-release-notes/new-relic-ios-15
---

### New features
Expand Down

0 comments on commit 533a1d7

Please sign in to comment.