Python ile Elasticsearch ve Kibana ML Kullanımı

pip install elasticsearch
pip install pandas
xpack.security.enabled: truexpack.security.transport.ssl.enabled: true
/usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive
ELASTIC_URL = ‘http://Sunucu_adi:9200' 

ELASTIC_USER = ‘elastic’
ELASTIC_PASSWORD = ‘olusturulan_sifre’
load_dotenv() 

elastic_url = os.getenv(“ELASTIC_URL”)
elastic_user = os.getenv(“ELASTIC_USER”)
elastic_pass = os.getenv(“ELASTIC_PASSWORD”)
es = Elasticsearch([elastic_url], basic_auth=(elastic_user, elastic_pass))
pip install matplotlib
def get_elasticsearchdata(): 
#elasticsearch query
query = {
“query”: {
“wildcard”: {
“(Filtrelenecek Sunucu Sütunu)”: “*(Buraya sunucu adı için anahtar kelime girilir)*”
} } }
part_of_index = scan(client=es, 
query=query,
index=’kpi_metrics_logs_2022.08.20',
raise_on_error=True,
preserve_order=False,
clear_scroll=True
)
result = list(part_of_index) 

temp = []
for hit in result: 
temp.append(hit[‘_source’])

df = pd.DataFrame(temp)
plt.plot(df[‘successaverageresponsetime’], 
df[‘averageresponsetime’],
‘r-’, label=’Success Average Response Time according to Average Response Time’,
linewidth=2,
markersize=5,
marker=’o’,
markerfacecolor=’blue’,
markeredgecolor=’red’,
markeredgewidth=2,
alpha=0.5)
plt.show()
Matplotlib ile Oluşan Line Chart
Kibana Dashboard’unda Hazırlanan Line Chart
df = get_elasticsearchdata() 
pd.set_option(‘display.max_rows’, None)
pd.set_option(‘display.max_columns’, None)
pd.set_option(‘display.width’, None)
pd.set_option(‘display.max_colwidth’, None)
df.columns.values.tolist()
resp = es.info() 
elastic_homepage = pd.DataFrame(resp)
es.indices.delete(index=’hedefteki_indis’, ignore=[400, 404])
successcount_array = df[‘successrequestcount’] 
totalcount_array = df[‘totalrequestcount’]
polymodel = np.poly1d(np.polyfit(totalcount_array, 
successcount_array,
3)
)

polyline = np.linspace(0, 30, 100)

plt.scatter(totalcount_array,
successcount_array)
plt.plot(polyline, polymodel(polyline),
‘r-’,
label=’Total Request Count with Poly Regression Model’
)
plt.show()
https://www.linkedin.com/in/tar%C4%B1k-%C3%B6zl%C3%BCk-08a9261b9/

--

--

Doğuş Teknoloji

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store