Meaghan Fitzgerald
Meaghan Fitzgerald

Reputation: 2839

Adding a Source to Librato Data When Sending through Segment

I am trying to figure out how to add a source to a metric in Librato when sending the information via Segment. I am using the python library and have tried creating a property for source (below) but it doesn't seem to be working properly.

Here's what I've got:

     userID = '12345'
     analytics.track(userID, 'event', {
          'value': 1,
          'integrations.Librato.source': userID
     })

I've also tried 'source' and 'Librato.source' as properties, which were referenced in Segment's documentation. Any suggestions?

Upvotes: 0

Views: 118

Answers (2)

Nik
Nik

Reputation: 39

Similarly for ruby, using the segment gem you can specify a source like so:

require 'analytics-ruby'

segment_token = 'asdfasdf' # The secret write key for my project

Analytics.init({
    secret: segment_token,
    #Optional error handler
    on_error: Proc.necd giw { |status, msg| print msg } })

Analytics.track(
    user_id: 123, 
    writeKey: segment_token, 
    event: 'segment.librato', 
    properties: { value: 42 }, context: { source:'my.source.name' })

Upvotes: 1

Meaghan Fitzgerald
Meaghan Fitzgerald

Reputation: 2839

You can't set the source of the Librato metric in the properties when sending from Segment, you need to send it as part of the context meta data. Librato does not accept any properties other than 'value' so nothing else you send as a property will be recorded. To set the source using the python library, the code needs to be as follows:

     userID = '12345'
     analytics.track(userID, 'event', {
          'value': 1
     }, {
          'Librato': {
               'source': userID
               }
     })

If you are are using javascript, it would be:

analytics.track({
  userId: '12345',
  event: 'event'
  properties: {
    value: 1
  },
  context: {
     'Librato': {
        'source': userID
     }
  }
});

Upvotes: 0

Related Questions