Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
This is a programmatic interface in Ruby for SignalFx's metadata and ingest APIs. It is meant to provide a base for communicating with SignalFx APIs that can be easily leveraged by scripts and applications to interact with SignalFx or report metric and event data to SignalFx.
This library supports Ruby versions 2.2.x and above.
Add this line to your application's Gemfile:
gem 'signalfx'
And then execute:
$ bundle
Or install it yourself as:
$ gem install signalfx
This library's protobuf dependency requires activesupport >=3.2. 5.x versions of activesupport require Ruby >=2.2.2, so users of older Ruby versions will need to install activesupport 4.2.10 before signalfx to avoid attempts of installing a more recent gem. Building and installing signalfx from source will fulfill this for you:
$ gem build signalfx.gemspec && gem install signalfx-<current_version>.gem
In order to send your data to the correct realm, you may need to configure your
endpoints. If no endpoints are set manually, this library uses the us0
realm by default.
If you are not in this realm, you will need to explicitly set the
endpoint config options below. To determine if you are in a different realm and need to
explicitly set the endpoints, check your profile page in the SignalFx
web application.
require('signalfx')
# Create client with alternate ingest endpoint
client = SignalFx.new('ORG_TOKEN', ingest_endpoint: 'https://ingest.{REALM}.signalfx.com',
stream_endpoint: 'https:/stream.{REALM}.signalfx.com')
To use this library, you will also need to specify an access token when requesting one of those clients. For the ingest client, you need to specify your organization access token (which can be obtained from the SignalFx organization you want to report data into). For the SignalFlow client, either an organization access token or a user access token may be used. For more information on access tokens, see the API's authentication documentation.
The default constructor SignalFx
uses Protobuf to send data to SignalFx. If it cannot send Protobuf, it falls back to sending JSON.
require('signalfx')
# Create client
client = SignalFx.new 'MY_SIGNALFX_TOKEN'
Optional constructor parameters:
false
by default.
If true
, the library will retrieve the Amazon instance unique
identifier and set it as AWSUniqueId
dimension for each
datapoint and event. Use this option only if your application is
deployed on Amazon AWS.This example shows how to report metrics to SignalFx, as gauges, counters, or cumulative counters.
require('signalfx')
client = SignalFx.new 'MY_SIGNALFX_TOKEN'
client.send(
cumulative_counters:[
{ :metric => 'myfunc.calls_cumulative',
:value => 10,
:timestamp => 1442960607000 },
...
],
gauges:[
{ :metric => 'myfunc.time',
:value => 532,
:timestamp => 1442960607000},
...
],
counters:[
{ :metric => 'myfunc.calls',
:value => 42,
:timestamp => 1442960607000},
...
])
The timestamp
must be a millisecond precision timestamp; the number of
milliseconds elapsed since Epoch. The timestamp
field is optional, but
strongly recommended. If not specified, it will be set by SignalFx's
ingest servers automatically; in this situation, the timestamp of your
datapoints will not accurately represent the time of their measurement
(network latency, batching, etc. will all impact when those datapoints
actually make it to SignalFx).
To send data through a HTTP proxy, set the environment variable http_proxy
with the proxy URL.
The SignalFlow client by default will use the proxy set in the http_proxy
envvar by default. To send SignalFlow websocket data through a separate proxy,
set the proxy_url
keyword arg on the client.signalflow
call.
Reporting dimensions for the data is also optional, and can be
accomplished by specifying a dimensions
parameter on each datapoint
containing a dictionary of string to string key/value pairs representing
the dimensions:
require('signalfx')
client = SignalFx.new 'MY_SIGNALFX_TOKEN'
client.send(
cumulative_counters:[
{ :metric => 'myfunc.calls_cumulative',
:value => 10,
:dimensions => [{:key => 'host', :value => 'server1'}]},
...
],
gauges:[
{ :metric => 'myfunc.time',
:value=> 532,
:dimensions=> [{:key => 'host', :value => 'server1'}]},
...
],
counters:[
{ :metric=> 'myfunc.calls',
:value=> 42,
:dimensions=> [{:key => 'host', :value => 'server1'}]},
...
])
See examples/generic_usecase.rb
for a complete code example for
reporting data.
Events can be sent to SignalFx via the send_event()
function. The
event type must be specified, and dimensions and extra event properties
can be supplied as well. Also please specify event category: for that
get option from dictionary EVENT_CATEGORIES
. Different categories of
events are supported. Available categories of events are USER_DEFINED
,
ALERT
, AUDIT
, JOB
, COLLECTD
, SERVICE_DISCOVERY
, EXCEPTION
.
require('signalfx')
timestamp = (Time.now.to_i * 1000).to_i
client = SignalFx.new 'MY_SIGNALFX_TOKEN'
client.send_event(
'<event_type>',
event_category: '<event_category>',
dimensions: { host: 'myhost',
service: 'myservice',
instance: 'myinstance' },
properties: { version: 'event_version' },
timestamp: timestamp)
See examples/generic_usecase.rb
for a complete code example for
sending events.
You can run SignalFlow computations as well. This library supports all of the functionality described in our API docs for SignalFlow. Right now, the only supported transport mechanism is WebSockets.
By default, this library connects to the us0
stream endpoint.
If you are not in this realm, you will need to explicitly set the
endpoint config options below when creating the client.
To determine if you are in a different realm and need to
explicitly set the endpoints, check your profile page in the SignalFx web application.
client = SignalFx.new(
'ORG_TOKEN',
ingest_endpoint: 'https://ingest.{REALM}.signalfx.com',
stream_endpoint: 'wss://stream.{REALM}.signalfx.com'
)
To create a new SignalFlow client instance from an existing SignalFx client:
signalflow = client.signalflow()
For the full API see the RubyDocs for
the SignalFlow
client
(the signalflow
var above).
There is also a demo script that shows basic usage.
Apache Software License v2. Copyright © 2015-2016 SignalFx
FAQs
Unknown package
We found that signalfx demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.