Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

BB ElasticSearch Status Page

Is there a status page we can use to validate that ElasticSearch is running?

Trying to figure out how to validate that ElasticSearch is running.  Is there a PID file that gets written when the process is running ?

For example, in BB you can hit the http://localhost:9006/xxx/status and it will provide you a value of RUNNING, ERROR, FIRST_RUN etc....

1 answer

1 accepted

0 votes
Answer accepted
Dave Chevell Atlassian Team May 08, 2020

Hey @Ken Ng

There are a couple of ways you can do this. One is "supported", one is a bit of a hack – I'll leave it to you which one you think is appropriate.

1. Hit the Elasticsearch service directly

Out of the box, Bitbucket Server comes with a bundled Elasticsearch instance. It runs on port 7992, bound to localhost (meaning it won't accept connections over the network) and it's protected via basic auth. 

The basic auth username and password can be found in $BITBUCKET_HOME/shared/search/buckler/buckler.yml, and looks something like this:

---
auth.basic.http.enabled: "true"
auth.basic.password: "randomlygeneratedpassword"
auth.basic.tcp.enabled: "true"
auth.basic.username: "bitbucket"

You can connect to it locally via http://localhost:7992 and see if it's running like so:

$ curl -u bitbucket:randomlygeneratedpassword http://localhost:7992/
{
"name" : "bitbucket_bundled",
"cluster_name" : "bitbucket_search",
"cluster_uuid" : "705tZVP2QM-rVskYJaM_pA",
"version" : {
"number" : "7.5.2",
"build_flavor" : "oss",
"build_type" : "zip",
"build_hash" : "8bec50e1e0ad29dad5653712cf3bb580cd1afcdf",
"build_date" : "2020-01-15T12:11:52.313576Z",
"build_snapshot" : false,
"lucene_version" : "8.3.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}

But what if you want to test it externally? Well, you could reconfigure the bundled Elasticsearch to listen on all network interfaces, but I wouldn't recommend that for various security reasons. Bitbucket has a way to test connectivity from the UI under Bitbucket Admin > Server settings > Elasticsearch > Test connection, but that doesn't help you if you want to automate it.

There's no officially documented or supported method to automate this, but you can essentially reproduce what the above "Test connection" button does via curl: 

2. Hit an undocumented API to get Bitbucket to test Elasticsearch for you

You can send a POST request to Bitbucket, along with the Elasticsearch URL you want Bitbucket to test (i.e. http://localhost:7992). In my example, I'll assume I'm running an instance at https://bitbucket.mycompany.com and the Bitbucket username/password admin:admin

$ BITBUCKET_URL=https://bitbucket.mycompany.com
$ BITBUCKET_USER=admin
$ BITBUCKET_PASS=admin
$ curl -i -u $BITBUCKET_USER:$BITBUCKET_PASS -X POST -H 'X-Atlassian-Token: no-check' -H 'Content-Type: application/json' -d '{"url":"http://localhost:7992/","username":"bitbucket","password":null}' $BITBUCKET_URL/rest/search-admin/latest/test-connection
HTTP/1.1 200
X-AREQUESTID: @1QLYW2Vx708x125x0
X-ASEN: SEN-500
X-AUSERID: 1
X-AUSERNAME: admin
X-Content-Type-Options: nosniff
vary: accept-encoding
Content-Type: application/json
Transfer-Encoding: chunked
Date: Fri, 08 May 2020 11:48:59 GMT


A successful request should return a HTTP status of 200. An unsuccessfull one should return a 40X response. Note that in my example above, I'm specifying the username for the bundled Elasticsearch instance, but no password. If you've left the bundled Elasticsearch instance to its defaults, the above command should work without any modification, excepting the Bitbucket URL and user credential variables.

Note that this method is not officially supported, and not a documented public API. This means it's subject to change with no warning. Bear that in mind!

I hope that helps Ken_Ng.

Cheers,

Dave 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,826 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you