![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
create customizable links to your graphite targets.
Creating links to view graphite visualizations isn't difficult, it's just
tedious. I generally find that there are a small number of targets ( i.e.
stats.timers.beta.request.users.index.{median,mean,upper_90}
) that I use. I
just switch out a few variables. glink
lets you create a template with
default variables, and then pass those variables in to create a url.
Install globally for cli usage
npm install -g glink
Or add to your current project for library usage
npm install --save glink
The CLI uses a config located at ~/.glinkrc
. If you don't have one, upon first
usage it will write a default config for you (see config.default.json
for the
current defaults). Once your config is there it will always use it. Update it as needed.
glink your items here --param1=value --param2=value
The config allows you to customize glink to be used with any type of target and
potential substitution varialbes you may need. The CLI simply takes each arg
you pass in and applies them, in order, to the variables defined in your config
template
. If you pass in less variables than you have defined in your config
template, the config templateDefaults
will be used.
For example, assume the following config:
{
"hostname": "graphite.example.com",
"template": "foo.bar.##controller##.##action##.median",
"templateDefaults": [
"##controller##===user",
"##action##===index"
],
"paramsDefaults": {}
}
Note that there are two variables defined in the template
(##controller##
and ##action##
), and two corresponding templateDefaults
that use the same
syntax (You choose whatever syntax works for you... more below).
So given that config, if you run the following:
glink admins create --from=-1w
You would end up with the following link:
https://graphite.example.com/render?target=foo.bar.admins.create.median&from=-1w
Note that ##controller##
has been substituted for the first arg (admins
),
and ##action##
with the second (create
).
Given the same config, the following:
glink admins --from=-1w
Would produce the following link:
https://graphite.example.com/render?target=foo.bar.admins.index.median&from=-1w
Note that the first arg has been used and the default for ##action##
(in this
case index
) was used as there was no second variable. The param
(--from=-1w
) was still used and added as a query param.
Params (arguments in the shape of --paramName=value
) are appended to the
created link as query params. You can define defaults using the
paramsDefaults
key in your config. This is a great place to define things
that you don't want to have to type into the CLI args, but will always want.
They are overriden by any values you pass in as arguments. See Graphite Graph
Parameter
Docs
for more info on the available params.
To use the library, pass in a config (same options as the cli config, but as a JS object), and an array of arguments (just like you do in the cli)
var glink = require('glink');
var config = {
hostname: 'graphite.example.com',
template: 'foo.bar.##controller##.##action##.mean',
templateDefaults: [
'##controller##***user',
'##action##***index',
],
templateDefaultDelimiter: '***',
paramsDefaults: {
width: '800',
height: '600'
}
};
var link = glink(config, ['admins', 'create', '--from=-4months'];);
// https://graphite.example.com/render?width=800&height=600&target=foo.bar.admins.create.mean&from=-4months
KeyName | Required? | Default | Notes |
---|---|---|---|
protocol | https | i.e. http or https | |
hostname | X | i.e. graphite.example.com | |
port | i.e. 443 | ||
template | X | define your variables as needed, with whatever syntax | |
templateDefaults | X | An array of strings | |
templateDefaultDelimiter | === | value used to split templateDefaults into variable and default value | |
paramsDefaults | {} | an object with key, value param and value defaults to apply | |
absoluteTimes | false | [experimental*] convert relative 'from' and 'until' times to absolute |
Your config template
is a template used to create a graphite target. You can
substitute variables out of the template based on arguments passed into glink.
Define your variables with any syntax you want. In the examples above we are
using a ##variableName##
syntax. These will be replaced with arguments or the
values in your templateDefaults
config values.
Your ability to use any variable naming in your template
is due to having
defaults defined in templateDefaults
. This config option holds an array of
strings in a special syntax:
##variableName##===defaultValue
Where ##variableName##
is whatever you used in your template
and defaultValue
is the default value to use should there not be enough args provided. In this
case we are using the ===
as a delimiter between the variable and default.
This is the default templateDefaultDelimiter
. Should you wish to use another
delimiter make sure you update the templateDefaultDelimiter
config value as
well.
For sanity define your templateDefaults
in the same order they appear in your template
.
There are several modules that may be useful on their own within glink. Here are a few of them:
createTarget(values:array, config:object)
The config object can be the same config object as used in the main glink function. createTarget
will look for template
, templateDefaults
, and templateDefaultDelimiter
. See the table above for explanations with regards to the config. The values
arg takes an array of values to be substituted into the template, in the order they are defined in the the templateDefaults
.
var createTarget = require('glink/lib/createTarget');
var config = {};
config.template = 'stats.timers.app.!!#controller#!!.!!#action#!!.mean';
config.templateDefaults = [
'!!#controller#!!===files',
'!!#action#!!===index'
];
var values = ['admin', 'show']
var target = createTarget(values, config);
// stats.timers.prod.request.admin.show.mean
wrapTarget(target:string, func:string, value:string|number)
Takes a graphite target (i.e. stats.timers.requests.users.index.mean
), and wraps it in a graphite function (i.e. alias
), with the value.
var wrapTarget = require('glink/lib/wrapTarget');
var target = 'stats.timers.requests.users.index.mean';
var newTarget = wrapTarget(target, 'alias', 'users index');
// "alias(stats.timers.requests.users.index.mean, 'users index')"
MIT License
(c) 2015 Jason Madsen
FAQs
generate graphite links
We found that glink demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.