DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Databases
  4. Announcing the Logz.io Search API

Announcing the Logz.io Search API

Logz.io has announced a new API that will enable users to safely and securely query the data that they are shipping to Logz.io using the Elasticsearch Search API DSL.

Daniel Berman user avatar by
Daniel Berman
·
Jan. 11, 17 · News
Like (1)
Save
Tweet
Share
3.86K Views

Join the DZone community and get the full member experience.

Join For Free

there’s nothing like starting a new year with new product-related announcements! in this case, i’m happy to inform our users of a new search api that will enable them to safely and securely query the data that they are shipping to logz.io using the elasticsearch search api dsl.

this api replaces the older query api, which was much more limited in scope and capabilities and will be deprecated in a few months.

why would you use the api to query elasticsearch instead of kibana? well, you could, for example, integrate with the api to create some kind of baseline for monitoring new services. as soon as a new service or host registers, you could use the api to match which of them are logging into elasticsearch.

below are some general guidelines on the api along with explanations of existing limitations and one simple example of how to use it.

licensing and limitations

for now, only our enterprise users will have access to the search api. likewise, we are currently limiting the number of search results to 10,000 (with paging).

queries can only be performed against data shipped over the prior two days (the current day and the one preceding it).

api tokens

to use the search api, you will first need to retrieve an api token. the token can be generated on the user tokens page in your account’s user settings:

user tokens

using the api

once you have the token, you can begin querying your data.

first, build your query in json format in a file. you can refer to the elasticsearch search api documentation for guidance on how to build the query.

for example, i’m going to query my account for a simple string and limit the search to one response:

{
 
   "from" : 0, "size" : 1,
    "query": {
        "query_string": {
            "query": "canada"
        }
    }
 }

then, build your api as follows (replace api-token with your token and query with the path to your query file):

curl -xpost 'https://api.logz.io/v1/search' --header "x-user-token: <api-token>" --header "content-type: application/json" --data-binary @<query>

and the response:

{  
  "hits":{  
     "total":984,
     "max_score":5.7908382,
     "hits":[  
        {  
"_index":"logz-xmywsrkbovjddxljvcahcxsrbifbccrh-161227_v2",
           "_type":"myfirewall",
           "_id":"avk9li_bmfctv-i4vosg",
           "_score":5.7908382,
           "_source":{  
              "geoip":{  
                 "timezone":"america/toronto",
                 "ip":"204.138.58.86",
                 "latitude":43.5924,
                 "continent_code":"na",
                 "city_name":"toronto",
                 "country_code2":"ca",
                 "country_name":"canada",
                 "country_code3":"can",
                 "region_name":"on",
                 "location":[  
                    -79.7611,
                    43.5924
                 ],
                 "real_region_name":"ontario",
                 "postal_code":"l5n",
                 "longitude":-79.7611
              },
 
"message":"<2016-12-27t20:31:13z><myfw-dc2>:src_ip=204.138.58.86,sport=4209,dst_ip=87.151.247.146,dport=443",
              "type":"myfirewall",
              "dst_ip":"87.151.247.146",
              "tags":[  
                 "_logz_http_bulk_json_8070",
                 "geoip"
              ],
              "src_ip":"204.138.58.86",
              "dport":443,
              "hostname":"myfw-dc2",
              "@timestamp":"2016-12-27t20:31:13.000+00:00",
              "sport":4209
           }
        }
     ]
  }

endnotes

  • be sure to use https in the request url. an http request will result in a “403” response.
  • the request body needs to comply with the elasticsearch search api . there are, however, some limitations that we highly recommend you review before you begin using the api.
  • more examples and documentation are available here .

we’d love to get your feedback. if you encounter any bugs, please open an issue on github or send us your comments to: support (at) logz.io.

happy querying!

API

Published at DZone with permission of Daniel Berman, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Connecting Your Devs' Work to the Business
  • Memory Debugging: A Deep Level of Insight
  • Best Practices for Writing Clean and Maintainable Code
  • What Should You Know About Graph Database’s Scalability?

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: