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 Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • API Testing Frameworks: How to Pick the Right One and Actually Use It Well
  • Mitigating Cache Stampedes in Dynamic API Translation Using Java 21 Virtual Threads
  • API Facade vs. Orchestration vs. Eventing, Now With AI in the Loop
  • HTTP QUERY in Java: The Missing Method for Complex REST API Searches

Trending

  • Going Stateless: Scaling MCP Servers to Cloud-Native Java and HTTP
  • Will AI Keep Us Stuck in 2020 Architectures?
  • When AI Agents Call Your Microservices: 5 Assumptions That No Longer Hold
  • 7 Essential Guardrails for Building AI SRE Agents
  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.

By 
Daniel Berman user avatar
Daniel Berman
·
Jan. 11, 17 · News
Likes (1)
Comment
Save
Tweet
Share
4.6K 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. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • API Testing Frameworks: How to Pick the Right One and Actually Use It Well
  • Mitigating Cache Stampedes in Dynamic API Translation Using Java 21 Virtual Threads
  • API Facade vs. Orchestration vs. Eventing, Now With AI in the Loop
  • HTTP QUERY in Java: The Missing Method for Complex REST API Searches

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook